#include <bits/stdc++.h>
using namespace std;
bool check(int a, int b, int c) {
  return (a + b > c && a + c > b && b + c > a);
}
map<tuple<int, int, int>, bool> checked;
int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if (check(i, j, i ^ j) && ((i ^ j) <= n)) {
        tuple<int, int, int> tri;
        if ((i ^ j) < j) {
          if ((i ^ j) < i) {
            tri = tuple<int, int, int>(i ^ j, i, j);
          } else {
            tri = tuple<int, int, int>(i, i ^ j, j);
          }
        } else {
          tri = tuple<int, int, int>(i, j, i ^ j);
        }
        if (!checked[tri]) {
          checked[tri] = true;
          ans++;
        }
      }
    }
  }
  cout << ans;
  return 0;
}
