#include using namespace std; typedef long long ll; signed main(){ ll N; cin >> N; ll maxv = 0; ll orgv = 0; while( N ){ orgv += N / 2; maxv = max( maxv, orgv + N / 2 ); } cout << maxv - orgv << endl; return 0; }