var
w,n,ans:longint;
f:array[1..60]of longint;
begin
assign(input,'bita.in');
assign(output,'bita.out');
reset(input);
rewrite(output);
read(n);
f[1]:=1;
for n:=2 to n do
begin
inc(f[1]);
w:=1;
while f[w]=2 do
begin
f[w]:=0;
inc(w);
inc(f[w]);
end;
w:=60;
while f[w]=0 do dec(w);
for w:=w-1 downto 1 do
if (f[w]=1)and(f[w+1]=1) then inc(ans);
end;
writeln(ans);
close(input);close(output);
end.