#include <bits/stdc++.h>
int tricheck(int a, int b, int c) {
  if ((abs(a - b) < c) && (c < a + b) && (abs(b - c) < a) && (a < b + c) &&
      (abs(a - c) < b) && (b < a + c)) {
    return 1;
  }
  return 0;
}
int main() {
  int n;
  scanf("%d", &n);
  int x = 1, y = 1, z = 1, counter = 0;
  clock_t ali = clock();
  for (x = n; x >= 1; x--) {
    for (y = x; y > x / 2; y--) {
      if ((x ^ y) < y && tricheck(x, y, x ^ y)) {
        counter++;
      }
    }
  }
  printf("%d", counter);
}
