#include <iostream>
using namespace std;
const int N=1000000;
int n, num0, num1, ans;
void cnt(int t)
{
if(t == 0) return;
cnt(t / 2);
if(t % 2 == 0)
num0++;
else
num1++;
}
int main()
{
cin >> n;
for(int i = 1; i <= n; i++){
num0 = num1 = 0;
cnt(i);
if(num1 > num0)
ans++;
}
cout << ans;
return 0;
}