program Project1;
var
  v,x,k,i,y,c,z,q:integer;
  d:array[1..3]of integer;
begin
  readln(v);
  d[1]:=1;
  d[2]:=2;
  d[3]:=5;
  x:=0;
  y:=1;
  c:=0;
  z:=0;
  if q>1 then
  begin
  q:=v;
  q:=q div 10;
  c:=c+1;
  k:=c-1;
  while v>0 do
  begin
  if k=0 then y:=1 else
  for i:=1 to k do
  y:=y*10;
  for i:=3 downto 1 do
  while z<v do
  begin
  z:=z+d[i]*y;
  x:=x+1;
  v:=v-z;
  k:=k-1;
  end;
  writeln(x);
  readln;
 end;
  readln;
  end;
  readln;
  readln;
end.