import math;A,B=map(int,input().split()) if A|B==0:print(1/4);exit() g=math.gcd(A,B);X=0;k=8*(g<=9)+2;F=A//g%2*B//g%2+1 while k+1:h=F*k*g+2;X+=(F*k+1)/h**h;k-=1 print(X)