#include <bits/stdc++.h>
using namespace std;
int check(int a, int b, int c) {
  if (a + b > c && a + c > b && b + c > a && ((a ^ b) ^ c) == 0) return 1;
  return 0;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int count = 0;
  for (int a = 1; a <= n; a++) {
    for (int b = a; b <= n; b++) {
      int c = a ^ b;
      if (check(a, b, c) == 1 && c <= n && c >= b) count++;
    }
  }
  cout << count << endl;
  return 0;
}
