#include <bits/stdc++.h>
using namespace std;
const long double PI = atan(1.0) * 4.0;
const long long int MOD = 1e9 + 7;
const long long int INF = 1e18;
const long double EPS = 0.0000001;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  long long int n, x, cnt = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j++) {
      x = i ^ j;
      if (x ^ j == i && i <= j && j <= x && x <= n && (i + j) > x) {
        cnt++;
      }
    }
  }
  cout << cnt << "\n";
  return 0;
}
