#include <bits/stdc++.h>
int a, b, c, ans, n;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    for (int j = i; j <= n; j++) {
      c = i ^ j;
      if (c >= j && i + j > c && c <= n) ans++;
    }
  printf("%d\n", ans);
}
