s = list(input().strip()) n = len(s) used = [False] * n count = 0 while True: pos = [] current_pos = -1 for target in 'KUROI': found = False for i in range(current_pos + 1, n): if not used[i] and (s[i] == target or s[i] == '?'): if s[i] == '?': s[i] = target # Replace '?' with the target character used[i] = True pos.append(i) current_pos = i found = True break if not found: break if len(pos) == 5: count += 1 else: break print(count)