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