#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int ans = 0;
  scanf("%d", &n);
  map<pair<int, pair<int, int> >, int> M;
  for (int i = 0; i <= n; ++i) {
    for (int j = i; j <= n; ++j) {
      int k = i ^ j;
      int v[] = {i, j, k};
      sort(v, v + 3);
      if (M.find(make_pair(v[0], pair<int, int>(v[1], v[2]))) == M.end()) {
        if (v[2] < v[1] + v[0] && v[0] + v[2] > v[1] && v[2] + v[1] > v[0] &&
            v[1] && v[2] && v[0] && v[2] <= n)
          ans++;
        M[make_pair(v[0], pair<int, int>(v[1], v[2]))] = 1;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
