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