program prvi;
var
v,c,b:int64;
begin
readln(v);
c:=0;
while v<>0 do
begin
b:=v mod 10;
while b>=5 do
begin
b:=b-5;
c:=c+1;
end;
while b>=2 do
begin
b:=b-2;
c:=c+1;
end;
while b>=1 do
begin
b:=b-1;
c:=c+1;
end;
v:=v div 10; 
end;
writeln(c);
end.