#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a, b, c, ans = 0;
  for (a = 1; a < n; a++) {
    for (b = a + 1; b <= n; b++) {
      c = a ^ b;
      if (c > a && c > b) {
        if (c > n) {
          continue;
        } else {
          if (a + b != c) {
            ans++;
          }
        }
      }
    }
  }
  cout << ans;
}
