#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
const long long mod = 1e9 + 7;
const long long N = 1e3 + 5, K = 105;
const int si = (1 << 20);
const long long add = 1e4;
const long long M = 1e4 + 5;
const double INFdb = 1e10;
const long long oo = 1e18;
int n;
int ans;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    for (int j = i; j <= n; ++j) {
      int xorr = i ^ j;
      if (!(i + j <= xorr || i > xorr || j > xorr || xorr > n)) ++ans;
    }
  }
  cout << ans;
  cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}
