#include <bits/stdc++.h>
using namespace std;
template <typename T>
void readv(vector<T> &a) {
  for (long long i = (0); i < (a.size()); i++) cin >> a[i];
}
void readi(vector<long long> &a) {
  for (long long i = (0); i < (a.size()); i++) {
    cin >> a[i];
    a[i]--;
  }
}
signed main() {
  long long N;
  cin >> N;
  long long ans = 0;
  for (long long a = (0); a < (N + 1); a++) {
    for (long long b = (0); b < (N - a + 1); b++) {
      if ((b & a) == b) ans++;
    }
  }
  cout << ans;
  return 0;
}
