#include <bits/stdc++.h>
int findPair(int n) {
  int a, b, counter = 0, u, v, temp1, temp2, temp3, temp4;
  for (u = 0; u <= n; u++) {
    for (v = 0; v <= n; v++) {
      for (a = 0; a <= n; a++) {
        for (b = 0; b <= n; b++) {
          temp1 = a ^ b;
          temp2 = a + b;
          if (temp3 == temp1 && temp4 == temp2) {
            break;
          }
          if (temp1 == u && temp2 == v) {
            temp3 = temp1;
            temp4 = temp2;
            counter++;
          }
        }
      }
    }
  }
  return counter;
}
int main(int argc, char *argv[]) {
  int n;
  scanf("%d", &n);
  printf("%d", findPair(n));
  return 0;
}
