#include <bits/stdc++.h>
using namespace std;
bool istriangle(int i, int j, int k) {
  int f = i;
  int s = j;
  int t = k;
  if (f + s > t && f + t > s && s + t > f) {
    return true;
  } else {
    return false;
  }
}
int main() {
  int n;
  cin >> n;
  unordered_map<int, vector<pair<int, int>>> m;
  int ans = 0;
  for (int i = 1; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      int x = i ^ j;
      m[x].push_back(make_pair(i, j));
    }
  }
  for (int i = 1; i <= n; i++) {
    if (m.find(i) != m.end()) {
      for (int j = 0; j < m[i].size(); j++) {
        if (i > m[i][j].second &&
            istriangle(m[i][j].first, m[i][j].second, i)) {
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
