s = input().strip() # dp represents the counts for each stage: K, KU, KUR, KURO, KUROI dp = [0, 0, 0, 0, 0] for c in s: # Determine possible characters for the current position if c == '?': candidates = ['K', 'U', 'R', 'O', 'I'] else: candidates = [c] new_dp = list(dp) for char in candidates: current = list(dp) if char == 'K': current[0] += 1 elif char == 'U': if current[0] > current[1]: current[1] += 1 elif char == 'R': if current[1] > current[2]: current[2] += 1 elif char == 'O': if current[2] > current[3]: current[3] += 1 elif char == 'I': if current[3] > current[4]: current[4] += 1 # Update new_dp to keep the maximum values for each stage for i in range(5): if current[i] > new_dp[i]: new_dp[i] = current[i] dp = new_dp print(dp[4])