#include <bits/stdc++.h>
using namespace std;
int main() {
  int sol = 0;
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= i; ++j) {
      for (int k = i - j; k <= j; ++k) {
        if (((k ^ j) ^ i) == 0 && k + j > i) ++sol;
      }
    }
  }
  cout << sol << '\n';
}
