#include using namespace std; typedef long long ll; #define REP(i,n) for(int i = 0;i < (n);i++) #define pb push_back const int INF = 1e9; const ll mod=1e9+7; int main(){ ll nn; cin >> nn; ll sum = 0; ll n = nn; while(n%2 == 0){ sum++; n /= 2; if(n == 0) break; } //cout << sum << endl; ll res = 0; REP(i,nn/2+1){ ll sumn = 0; ll r = i; while(r%2 == 0 && r != 0){ sumn++; r /= 2; } //cout << sumn << endl; if(sum > sumn && i != 0) res++; } if(nn%2 == 0 && nn != 0) cout << (res-1)*2+1 <