var
n,i,j,z,t,sum:longint;
a:array[0..100000]of longint;
begin
assign(input,'bita.in');
assign(output,'bita.out');
reset(input);
rewrite(output);
readln(n);
j:=0;
for i:=1 to n do
begin
z:=i;
repeat
j:=j+1;
a[j]:=z mod 2;
z:=z div 2;
until z=0;
for t:=j downto 1 do
begin
if(a[t]=1)and (a[t]=a[t-1]) then sum:=sum+1;
end;
j:=0;
end;
writeln(sum);
close(input);
close(output);
end.