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