#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int ans = 0;
  map<tuple<int, int, int>, bool> used;
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j++) {
      int k = i ^ j;
      if (k <= n && i + j > k && k + j > i && i + k > j) {
        ans++;
      }
    }
  }
  cout << ans / 3 << "\n";
}
