#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  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 (c < b || c > n) continue;
      if (a + b > c) ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}
