#include "bits/stdc++.h" #define int long long using namespace std; using ll = long long; using P = pair>; const ll INF = (1LL << 61); ll mod = 1000000007; vector enum_divisors(ll N) { vector res; for (ll i = 1; i * i <= N; i++) { if (N % i == 0) { res.push_back(i); if (N / i != i)res.push_back(N / i); } } sort(res.begin(), res.end()); return res; }int beki[40]; signed main() { ios::sync_with_stdio(false); cin.tie(0); int N; cin >> N; int now = 1; for (int i = 0; i < 40; i++) { beki[i] = now; now *= 2; } int ans = 0; for (ll i = 1; i * i <= N; i++) { if (N % i == 0) { int now = i, now2 = N / i; if ((now | now2) != now2)continue; int t = (now & now2); int cnt = 0; for (int j = 0; j < 40; j++) { if (t >> j & 1)cnt++; } if (cnt == 0)continue; ans += beki[cnt - 1]; } } cout << ans << endl; return 0; }