#include <bits/stdc++.h>
using namespace std;
int main() {
  set<pair<int, pair<int, int> > > st;
  int n, cnt = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= i; j++) {
      int x, y;
      x = i ^ j;
      if (i + j > x && x + i > j && x + j > i & x > 0 && x <= n) {
        int a, b, c;
        a = max(i, max(j, x)), b = min(i, min(j, x));
        c = (i + j + x) - a - b;
        pair<int, int> pii(b, c);
        st.insert(pair<int, pair<int, int> >(a, pii));
      }
    }
  }
  cout << st.size() << endl;
  return 0;
}
