program cc(input,output);
var
a:array[0..1000000]of longint;
n,i,j,x,w,q:longint;
begin
assign(input,'bita.in');
assign(output,'bita.out');
reset(input);
rewrite(output);
read(n);
for q:=1 to n do
begin
w:=q;
repeat
inc(i);
a[i]:=w mod 2;
w:=w div 2;
until w=0;
for j:=i downto 1 do
begin
if (a[j]=1)and(a[j]=a[j-1]) then x:=x+1;
end;
i:=0;
end;
writeln(x);
close(input);
close(output);
end.