#include <bits/stdc++.h>
using namespace std;
bool istriangle(int i, int j, int k) {
  return (i + j > k && i + k > j && k + j > i);
}
int main() {
  int n;
  cin >> n;
  int counter = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      int k = i ^ j;
      if (k > n) continue;
      if (i < j && j < k && istriangle(i, j, k)) {
        counter++;
      }
    }
  }
  cout << counter;
}
