Two Function Conundrum

All submissions for this problem are available.
This is probably the easiest task of this problem set. To help you understand the task let us define two key functions:
Let f(p,q) be the set of all integers x such that (p mod x + q mod x) >= x. For example:
f(1,7) = {2,4,8} f(5,7) = {2,3,4,6,8,9,10,11,12} f(6,7) = {4,8,9,10,11,12,13}
Let E(n) = number of integers {0,1,2, ... ,n1} that are relatively prime to n.
Given p and q, your task is to find the summation of E(x) for all x in f(p,q).
Input
The first and the only line of the input contains two (space separated) integers denoting p and q as described in the problem set.
Output
Output the required summation.
Constraints
Both p and q will nonnegative and can have atmost 300000 decimal digits each.
Example
Input: 1 7 Output: 7
Explanation
For the test case: p = 1 and q = 7,
we have, f(1,7) = {2,4,8}, then E(2) + E(4) + E(8) = 1 + 2 + 4 = 7
Author:  Debanjan 
Tags  Debanjan 
Date Added:  26092013 
Time Limit:  1 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.5, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, CLOJ, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 