#include #include #include #include #include #include using namespace std; typedef long long LL; LL st[70]; set s; queue q; int main() { st[0] = 1; for (int i = 1; i < 63; i++) st[i] = st[i-1] << 1; for (int i = 0; i < 63; i++) st[i]--; LL n; while (scanf("%I64d", &n) != EOF) { s.clear(); s.insert(n); q.push(n); while (!q.empty()) { LL a = q.front(), b, c; q.pop(); if (a == 0) continue; for (int i = 0; i < 63; i++) if (a-1-st[i] <= st[i+1]) { b = a - st[i] - 1; c = st[i]; break; } if (s.insert(b).second) q.push(b); if (s.insert(c).second) q.push(c); } printf("%d\n", s.size()-1); } return 0; }