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