from math import * A, B = map(int, input().split()) A, B = abs(A), abs(B) ans = 0.25 if A == B == 0: print(ans) elif A == 0 or B == 0: c = max(A, B) ans = 0 for i in range(1, 30, c): ans += 1/((i + 1) ** (i + 1)) print(ans) else: g = gcd(A, B) ans = 0 for i in range(30): for j in range(30): if i % g == j % g == 0: ans += 1/((i + j + 2) ** (i + j + 2)) print(ans)