program isplata;
uses math;
var
  b: longint;
  t, z, i: shortint;
  v: qword;
  n: array [1..60] of qword;
begin
  read(v);

  t := 57;
  b := 0;
  z := 0;

  for i := 0 to 18 do begin
    n[i+1+z] := 10 ** i;
    n[i+2+z] := n[i+1+z]*2;
    n[i+3+z] := n[i+1+z]*5;
    z := z + 2;
  end;

  while v <> 0 do begin
    if n[t] <= v then begin
      v := v - n[t];
      b := b + 1;
    end
    else t := t - 1;
  end;

  write(b);
end.