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