#include<cstdio>
#include<cmath>
using namespace std;
typedef long long ll;
ll n,k;
void getphi(ll x){
ll ans=1;
for (int i=2;i<=sqrt(x);i++)
if (!(x%i)){
ans*=(i-1);x/=i;
while (!(x%i)) ans*=i,x/=i;
}
if (x!=1) ans*=(x-1);
printf("%lld\n",ans);
}
int main()
{
freopen("skyfuc.in","r",stdin);
freopen("skyfuc.out","w",stdout);
while (~scanf("%lld%lld",&n,&k)) getphi(n+k+1);
return 0;
}