class Solution:
def minNumberOfFrogs(self, s: str) -> int:
d = [float("inf"),0,0,0,0,0]
dic = {"c":1, "r":2, "o":3,"a":4,"k":5}
ans = 0
for c in s:
d[dic[c]-1] -= 1
d[dic[c]] += 1
if min(d) < 0:
return -1
ans = max(ans,sum(d[1:5]))
return ans if sum(d[1:5]) == 0 else -1