#include <bits/stdc++.h>
using namespace std;
const long long base = 311, mod = 1e9 + 7, N = 1e6 + 11, inf = INT_MAX;
long long n, cnt = 0;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (long long a = 1; a <= n; a++) {
    for (long long b = a; b <= n; b++) {
      long long c = a ^ b;
      if (c < b || c > n) continue;
      if (b + c > a && c + a > b && a + b > c) {
        cnt++;
      }
    }
  }
  cout << cnt;
}
