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