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