var
i,j,k,max,n :longint;
t:text;
c:array[1..100] of char;
s:string;
begin
assign(t,'chashu.in');
reset(t);
readln(t,n);
close(t);
assign(t,'chashu.out');
rewrite(t);
for i:=(trunc(exp((k-1)*ln(10)))) to trunc(exp((k)*ln(10)))-1 do
begin
n:=0;
str(i,s);
for j:=1 to length(s) do
if ord(s[j])-ord('0')=3 then inc(n);
if n mod 2 =0 then begin inc(max);;end;
end;
write(t,max);
close(t);
end.