#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int ans = 0;
  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) {
        if (c >= b && c <= n) {
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
