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