#include using namespace std; using LL = long long; using ULL = unsigned long long; #define rep(i,n) for(int i=0; i<(n); i++) LL GCD(LL a, LL b) { return b ? GCD(b, a % b) : a; } double F(LL x) { return pow(1. / double(x), double(x)); } int main() { cout << fixed << setprecision(10); double ans = 0.; LL A, B; cin >> A >> B; A = abs(A); B = abs(B); if (A != 0 && B != 0) { LL G = GCD(A, B); A /= G; B /= G; if (A % 2 == 1 && B % 2 == 1) { rep(x, 20) rep(y, 20) { if (x % G != 0 || y % G != 0) continue; if ((x + y) % 2 == 1) continue; ans += F(x + y + 2); } } else { rep(x, 20) rep(y, 20) { if (x % G != 0 || y % G != 0) continue; ans += F(x + y + 2); } } } else if (A == 0 && B == 0) { ans = 0.25; } else { if (B == 0) swap(A, B); rep(x, 20) rep(y, 20) { if (x % B != 0 || y % B != 0) continue; ans += F(x + y + 2); } } cout << ans << endl; return 0; }