import math A,B=map(int,input().split()) if A<0:A=-A if B<0:B=-B G=math.gcd(A,B) ans=0 for n in range(100): x=n+1 y=2+n*G y=pow(y,y) ans+=x/y print(ans)