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