import math A,B=map(int,input().split()) if A==B==0: print(0.25) else: g=math.gcd(A,B) X=0 T=8*(g<=20)+2 F=(A//g)%2*(B//g)%2+1 for k in range(0,T): h=F*k*g+2 X+=(F*k+1)/(h**h) print(X)