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