#include <bits/stdc++.h>
using namespace std;
struct abc {
  long long int val, x;
};
bool compare(abc a1, abc a2) { return a1.val < a2.val; }
const long long int mod = 2e9 + 7;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int n, ans = 0;
  cin >> n;
  for (long long int i = 1; i <= n; i++) {
    for (long long int j = i; j <= n; j++) {
      long long int k = 0 ^ i ^ j;
      if (k <= n && k < i + j && k >= j) ans++;
    }
  }
  cout << ans;
}
