#include<iostream>
#include<fstream>
using namespace std;
const int maxn=50;
int n;
int count(int x)
{
int i,c=0;
int b[maxn],p=0;
while(x>0){
int t=x%2;x=x/2;
b[p++]=t;
}
for(i=0;i<p-1;i++)
if(b[i]==1&&b[i+1]==1) c++;
return c;
}
int main()
{
freopen("bita.in","r",stdin);
freopen("bita.out","w",stdout);
cin>>n;
int c;
for(int i=1;i<=n;i++)
c+=count(i);
cout<<c;
return 0;
}