type
arr=array[1..5000] of byte;
var
n,i,ans:longint;
a:arr;
function get(a:arr;k:longint):longint;
var i,j:longint;
begin
j:=0;
for i:=1 to k-1 do
if (a[i]=a[i+1])and(a[i]=1) then inc(j);
get:=j;
end;
function switch(n:longint):longint;
var i:longint;
begin
i:=0;
fillchar(a,sizeof(a),0);
while n<>0 do
begin
inc(i);
a[i]:=n mod 2;
n:=n div 2;
end;
switch:=get(a,i);
end;
begin
assign(input,'bita.in');
reset(input);
assign(output,'bita.out');
rewrite(output);
readln(n);
for i:=1 to n do
ans:=ans+switch(i);
writeln(ans);
close(input);
close(output);
end.