#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9 + 7;
const int N = 1e6 + 10;
int main() {
  int ans = 0;
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j++) {
      int x = i ^ j;
      if (x >= j && x <= n && x < i + j) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
