#include #include #include #include using namespace std ; typedef long long LL ; #define clr( a , x ) memset ( a , x , sizeof a ) #define cpy( a , x ) memcpy ( a , x , sizeof a ) const int MAXN = 100 ; LL p[MAXN] , n ; map < LL , int > mp ; int ans , cnt ; void dfs ( LL n , LL nn , LL R ) { if ( mp.count ( n + nn ) ) return ; ans ++ ; mp[n + nn] = 1 ; n >>= 1 ; R >>= 1 ; LL x = min ( nn , R ) ; LL y = nn - x ; if ( n + x ) dfs ( n , x , R ) ; if ( n + y ) dfs ( n , y , R ) ; } void solve () { mp.clear () ; LL nn = n ; ans = cnt = 0 ; while ( nn >= p[cnt] ) { nn -= p[cnt] ; ++ cnt ; } if ( cnt == 0 ) { printf ( "%d\n" , cnt ) ; return ; } dfs ( n - nn , nn , p[cnt] ) ; printf ( "%d\n" , ans ) ; } int main () { p[0] = 1 ; for ( int i = 1 ; i < MAXN ; ++ i ) { p[i] = p[i - 1] * 2 ; } while ( ~scanf ( "%lld" , &n ) ) solve () ; return 0 ; }