var
a:array[1..20000000]of longint;
b,c,d,e,i,n:longint;
begin
assign(input,'bita.in');
assign(output,'bita.out');
reset(input);
rewrite(output);
read(n);
for d:=1 to n do
begin
while b<>0 do
begin
b:=d;
i:=i+1;
a[i]:=b mod 2;
b:=b div 2;
end;
c:=i;
for i:=1 to c do
begin
if (a[i]=1)and(a[i]=a[i+1]) then e:=e+1;
end;
i:=0;
end;
write(e);
close(input);
close(output);
end.