def max_kuroi_subsequences(s): target = "KUROI" counts = {c: 0 for c in target} for c in s: if c in counts: counts[c] += 1 M = s.count('?') # Step 1: Compute maximum possible t based on counts and M sum_counts = sum(counts[c] for c in target) max_t = (sum_counts + M) // 5 low, high = 0, max_t best_t = 0 while low <= high: mid = (low + high) // 2 needed = 0 for c in target: if counts[c] < mid: needed += (mid - counts[c]) if needed > M: break if needed <= M: best_t = mid low = mid + 1 else: high = mid - 1 t = best_t # Step 2: Compute the number of subsequences using DP dp = [0] * (len(target) + 1) dp[0] = 1 for c in s: for i in reversed(range(len(target))): if c == target[i] or c == '?': dp[i+1] += dp[i] dp_result = dp[len(target)] # The answer is the minimum of t and dp_result return min(t, dp_result) # Read input s = input().strip() print(max_kuroi_subsequences(s))