#include <bits/stdc++.h>
using namespace std;
map<pair<pair<int, int>, int>, int> mp;
int check[3000];
int main() {
  vector<int> v;
  int arr[5];
  int n;
  scanf("%d", &n);
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j++) {
      int x = i ^ j;
      if (i + j > x && i + x > j && j + x > i) {
        if (x <= n && x > 0) {
          arr[0] = i;
          arr[1] = j;
          arr[2] = x;
          sort(arr, arr + 3);
          if (mp[make_pair(make_pair(arr[0], arr[1]), arr[2])] == 0) {
            cnt++;
            mp[make_pair(make_pair(arr[0], arr[1]), arr[2])]++;
          }
        }
      }
    }
  }
  printf("%d", cnt), printf("\n");
  return 0;
}
