S = raw_input() KUROI = ["K", "U", "R", "O", "I", "?"] string = "" kurolist = [0]*5 ans = 0 for s in S: if s in KUROI: string += s print string for s in string: if s == "K": kurolist[0] += 1 elif s == "U": if kurolist[0] > 0: kurolist[1] += 1 elif s == "R": if kurolist[0] > 0 and kurolist[1]> 0: kurolist[2] += 1 elif s == "O": if kurolist[0] > 0 and kurolist[1] > 0 and kurolist[2] > 0: kurolist[3] += 1 elif s == "I": if kurolist[0] > 0 and kurolist[1] > 0 and kurolist[2] > 0 and kurolist[3] > 0: kurolist[4] += 1 elif s == "?": kurolist[kurolist.index(min(kurolist))] += 1 if min(kurolist) > 0: ans += 1 kurolist = [x-1 for x in kurolist] print ans