#include <bits/stdc++.h>

using namespace std;

using ll = long long;

vector<ll> getdiv(ll n) {
    ll i = 1;
    vector<ll> ans;
    while (i * i <= n) {
        if (n % i == 0) {
            ans.push_back(i);
            if (i * i != n) {
                ans.push_back(n/ i);
            }
        }
        i++;
    }
    return ans;
}

int main() {
    ll x; cin >> x;
    vector<ll> d = getdiv(x);
    ll val = 0;
    ll all = 0;
    for(int i = 0; i < (1 << d.size()); i++) {
        ll a = x;
        bitset<50> p = i;
        for(int j = 0; j < d.size(); j++) {
            if(p[j]) a ^= d[j];
        }
        all++;
        if (__builtin_popcount(a) >= __builtin_popcount(x)) val++;
    }
    cout.precision(6);
    cout << fixed << (double)((double)val / (double)all);
}
