S = input().strip() n = len(S) used = [False] * n count = 0 target = ['K', 'U', 'R', 'O', 'I'] while True: positions = [-1] * 5 current_pos = -1 for i in range(5): found = False for j in range(current_pos + 1, n): if not used[j]: c = S[j] if c == '?': c = target[i] if c == target[i]: positions[i] = j used[j] = True current_pos = j found = True break if not found: break else: count += 1 continue break print(count)