#include #include #include #include #include #include using namespace std; typedef long long LL; typedef vector VI; #define REP(i,n) for(int i=0, i##_len=(n); i inline void amin(T &a, const T &b) { if (b inline void amax(T &a, const T &b) { if (a>=1) { // if (y &1) r *= x; // x *= x; // } // return r; // } // LL nCk(LL n, LL k) { // LL ret = 1; // amin(k, n-k); // REP (i, k) ret = ret * (n-i) / (i+1); // return ret; // } // LL F(LL x) { // LL ret = 0; // LL sgn = 1; // REP (k, x+1) { // ret += sgn * pow(2, 2*x-2*k) * nCk(2*x-k+1, k); // sgn = -sgn; // } // return ret; // } LL phi(LL x) { LL r = x; for (LL i=2; i*i<=x; i++) { if (x % i == 0) { r = r / i * (i-1); x /= i; while (x % i == 0) x /= i; } } if (x > 1) r = r / x * (x-1); return r; } int main() { LL N, X; while (scanf("%lld%lld", &N, &X) != EOF) { N += X + 1; printf("%lld\n", phi(N)); } return 0; }