/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2021.04.01 02:05:49
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int bitpopcount(ll n) {
    int res = 0;
    while (n) {
        if (n & 1) res++;
        n >>= 1;
    }
    return res;
}

template<typename T, typename U>
T _pow(T k, U n, T unity = 1) {
    while (n > 0) {
        if (n & 1) {
            unity *= k;
        }
        k *= k;
        n >>= 1;
    }
    return unity;
}
int main() {
    int n;cin >> n;
    ll ans = 0;
    for (int i = 1; i * i <= n; i++) {
        if (n % i != 0) continue;
        if ((i & (n/i)) != i) continue;
        
        ans += _pow(2,bitpopcount(i)-1);
    }
    cout << ans << endl;
    return 0;
}