program Project1;
uses math;
var
  v,x,k,i:integer;
  z:float;
  d:array[1..3] of integer;
begin
  readln(v);
  d[1]:=1;
  d[2]:=2;
  d[3]:=5;
  X:=0;
  while z<v do
begin
  for k:=1 to 1000000000 do
  for i:=1 to 3 do
  z:=d[i]*power(10,k);
  x:=x+1;
end;
  writeln(x);
  readln;
end.