s = input().strip() n = len(s) used = [False] * n target = ['K', 'U', 'R', 'O', 'I'] count = 0 while True: ptr = 0 indices = [] for c in target: found = False while ptr < n: if not used[ptr] and (s[ptr] == c or s[ptr] == '?'): indices.append(ptr) used[ptr] = True ptr += 1 found = True break ptr += 1 if not found: break if len(indices) == 5: count += 1 else: break print(count)