#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
bool can[5005][2505];
int ans;
long long n;
void solve() {
  scanf("%lld", &n);
  assert(n <= 5000);
  for (int a = 0; a <= n; ++a) {
    for (int b = 0; b <= n; ++b) {
      if ((a & b) * 2 + (a ^ b) <= n) {
        can[a ^ b][a & b] = 1;
      }
    }
  }
  for (int x = 0; x <= n; ++x) {
    for (int y = 0; y + y <= n; ++y) {
      ans += can[x][y];
    }
  }
  printf("%d", ans);
}
int main() {
  int tt = 1;
  while (tt--) {
    solve();
  }
  return 0;
}
