#include <bits/stdc++.h>
using namespace std;
map<long long, long long> dp;
int main() {
  long long n;
  while (~scanf("%lld", &n)) {
    dp[0] = 1;
    dp[1] = 2;
    for (int i = 2; i <= n; i++)
      dp[i] = dp[i / 2] + dp[(i - 1) / 2] + dp[(i - 2) / 2];
    printf("%lld\n", dp[n]);
  }
  return 0;
}
