143165576
 1919020031
 1204252996
 210637432
 724264821
 1741
 619489590
 1199537418
 1075765759
 747976826
 638486017
 58438190
 1285316221
 186925426
 1180540990
 833393692
 1818960378
 2000000000
 0
 1309028227
 514714359
 624205168
 1795248373
 643201595
 1304312649

14 3 3 4 5 2 4 4 2 4 6 4 3 4 5 3 5 4 1 5 3 4 5 5 8
#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
vector<long long> base;
long long power(long long x, long long y) {
  long long ret = 1;
  while (y) {
    if (y & 1) ret *= x;
    y >>= 1;
    x *= x;
  }
  return ret;
}
int trans(int u) {
  if (u <= 9) return u + '0';
  return u - 10 + 'A';
}
int cal(char c) {
  if (c == '0') return 1;
  if (c == '6') return 1;
  if (c == '8') return 2;
  if (c == '9') return 1;
  if (c == 'A') return 1;
  if (c == 'B') return 2;
  if (c == 'D') return 1;
  return 0;
}
int main(int argc, char* argv[]) {
  for (int i = 0; i < 10; ++i) base.emplace_back(power(16, i));
  long long n;
  cin >> n;
  int f = 0;
  vector<char> g;
  for (int i = base.size() - 1; i >= 0; --i) {
    for (int j = 15; j >= 0; --j)
      if (n >= 1LL * j * base[i]) {
        if (j)
          g.emplace_back(trans(j));
        else if (f)
          g.emplace_back('0');
        f |= (j > 0);
        n -= (1LL * j * base[i]);
        break;
      }
  }
  int ans = 0;
  for (auto it : g) ans += cal(it);
  cout << ans << endl;
  return 0;
}
