#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:5000000000")
void ending() { exit(0); }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, kol = 0;
  cin >> n;
  for (int a = 1; a <= n; a++) {
    for (int b = a; b <= n; b++) {
      int c = a ^ b;
      if (a + b > c && a + c > b && b + c > a && c >= b && c <= n) {
        kol++;
      }
    }
  }
  cout << kol;
  ending();
  ;
}
