#include <bits/stdc++.h>
using namespace std;
long long n;
map<long long, int> mp;
long long calc(long long n) {
  if (mp.count(n)) return mp[n];
  return calc(n >> 1) + calc((n - 1) >> 1) + calc((n - 2) >> 1);
}
int main() {
  scanf("%lld", &n);
  mp[0] = 1;
  mp[1] = 2;
  printf("%lld", calc(n));
  return 0;
}
