from decimal import Decimal import decimal import sys import math a,b=map(int,input().split()) decimal.getcontext().prec = 10000 if a==0 and b==0: print("0.25") sys.exit() ans=Decimal(0) for i in range(1,100): for j in range(1,100): k=math.gcd(a,b) if(a!=b and i%k==1 and j%k==1): if (i/k+j/k)%2==0 or (a/k+b/k)%2==1: ans+=Decimal(1)/Decimal((i+j)**(i+j)) if a!=b and k==1: if (i/k+j/k)%2==0 or (a/k+b/k)%2==1: ans+=Decimal(1)/Decimal((i+j)**(i+j)) print(ans)