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