#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:102400000,102400000")
const int N = 200005;
int n;
int main() {
  scanf("%d", &n);
  long long ans = 0;
  for (int a = 1; a <= n; ++a)
    for (int b = a; b <= n; ++b) {
      int c = a ^ b;
      if (c <= n && c >= b && a + b > c) ++ans;
    }
  printf("%lld\n", ans);
  return 0;
}
