var
k5, k9, k45, k, i, x: integer;
begin
k5 := 0; k9 := 0; k45 := 0;
while True do
begin
readln(x);
if x = 0 then
break;
if (x mod 5 = 0) and (x mod 9 <> 0) then
k5 += 1;
if (x mod 5 <> 0) and (x mod 9 = 0) then
k9 += 1;
if x mod 45 = 0 then
k45 += 1;
end;
k := k5+k9-k45;
write(k)
end.