#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  int n;
  scanf("%d", &n);
  int sol = 0;
  int vs[2503] = {0};
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      int c = i ^ j;
      if ((i + j > c) && (i + c > j) && (j + c > i) && (c > j && c <= n)) {
        sol++;
      }
    }
  }
  cout << sol << endl;
}
