#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int out = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      int de = i ^ j;
      if ((de) <= n && (de) != 0 && (de) >= j && (i + j) != de) {
        out++;
      }
    }
  }
  cout << out;
  return 0;
}
