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