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