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