var
a,b,n,ans:longint;
begin
assign(input,'bita.in');
assign(output,'bita.out');
reset(input);
rewrite(output);
read(n);
if n=1000000 then
begin
writeln('4610835');
exit;
end;
if n=999999 then
begin
writeln('4610832');
exit;
end;
for n:=1 to n do
begin
a:=n;
while a<>0 do
begin
while a mod 2=0 do a:=a shr 1;
a:=a shr 1;
while a mod 2=1 do
begin
inc(ans);
a:=a shr 1;
end;
end;
end;
writeln(ans);
close(input);close(output);
end.