#include <bits/stdc++.h>
using namespace std;
bool check(int a, int b, int c) {
  if (a + b > c) return true;
  return false;
}
int main() {
  int n;
  int a, b, c;
  scanf("%d", &n);
  int count = 0;
  for (a = 1; a <= n; a++) {
    for (b = a; b <= n; b++) {
      c = a ^ b;
      if (c >= b && c <= n && check(a, b, c)) count++;
    }
  }
  cout << count << endl;
  return 0;
}
