#include <bits/stdc++.h>
const int MAXS = 4096 + 10;
const int MAXN = 2500 + 10;
int main() {
  int n;
  scanf("%d", &n);
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      int m = i ^ j;
      if ((i + j) > m && m > j && m <= n) {
        cnt++;
      }
    }
  }
  printf("%d", cnt);
}
