DIGIT0 - Số 0 tận cùng
Tác giả: ladpro98
Ngôn ngữ: Pascal
program digit0;
uses math;
const fi='';
var mu:array[1..6] of longint;
mu2:array[1..14] of longint;
ch:array['a'..'z'] of longint;
inp:text;
c:char;
n:longint;
s:ansistring;
res1,res2:int64;
procedure input;
var c:char;
begin
assign(inp,fi);
reset(inp);
n:=0;
readln(inp,s);
n:=length(s);
close(inp);
end;
procedure init;
var i:longint;
begin
mu[1]:=5;
for i:=2 to 6 do
begin
mu[i]:=mu[i-1]*5;
end;
mu2[1]:=2;
for i:=2 to 14 do mu2[i]:=mu2[i-1]*2;
for i:=1 to n do
inc(ch[s[i]]);
end;
function calc(k:longint):longint;
var i,t:longint;
begin
i:=1;
t:=0;
while mu[i]<=k do
begin
inc(t,trunc(k/mu[i]));
inc(i);
end;
exit(t);
end;
function calc2(k:longint):longint;
var i,t:longint;
begin
i:=1;
t:=0;
while mu2[i]<=k do
begin
inc(t,trunc(k/mu2[i]));
inc(i);
end;
exit(t);
end;
begin
input;
init;
res1:=calc(n);
res2:=calc2(n);
for c:='a' to 'z' do
begin
if ch[c]>=5 then
dec(res1,calc(ch[c]));
if ch[c]>=2 then dec(res2,calc2(ch[c]));
end;
write(min(res1,res2));
end.