#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, c = 0;
  scanf("%d", &n);
  for (int i = 0; i <= n; i++) {
    for (int j = i; j <= n; j++) {
      int x = i ^ j;
      if (x < j || x > n || x >= i + j) continue;
      c++;
    }
  }
  printf("%d", c);
}
