#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) {
      int c = (a ^ b);
      if (c <= n && c >= a && c >= b && a + b > c) ++cnt;
    }
  }
  cout << cnt;
  return 0;
}
