#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, t = 0;
  cin >> n;
  for (int a = 1; a <= n; a++) {
    for (int b = 1; b <= a; b++) {
      int c = a ^ b;
      if (c < b && b + c > a) t++;
    }
  }
  cout << t;
}
