#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int num;
  int flag;
  long long int count = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      num = (i ^ j);
      if (num > 0 && num <= n) {
        flag = 0;
        if (i + j <= num) {
          flag = 1;
        } else if (i + num <= j) {
          flag = 1;
        } else if (num + j <= i) {
          flag = 1;
        }
        if (flag == 0) {
          count++;
        }
      }
    }
  }
  cout << count / 6 << endl;
  return 0;
}
