import itertools S = input() def solve(S): S = preprocess(S) target = ['K', 'U', 'R', 'O', 'I'] count = 0 while S: for pattern in generate_patterns(target): idxs = find_pat(S, pattern) if len(idxs) == len(pattern): count += 1 S = [c for i, c in enumerate(S) if i not in idxs] S = preprocess(S) break else: break return count def find_pat(S, pattern): len_pat = len(pattern) idxs = [] idx = 0 for i, c in enumerate(S): if c == pattern[idx]: idxs.append(i) idx += 1 if idx == len_pat: return idxs return idxs def preprocess(S): S2 = [c for c in S if c in 'KUROI?'] for i, c in enumerate(S2): if c == 'K' or c == '?': S3 = S2[i:] break else: return [] for i in range(len(S3) - 1, -1, -1): if S3[i] == 'I' or S3[i] == '?': S4 = S3[:i + 1] break else: return [] if len(S4) < 5: return [] return S4 def generate_patterns(target): n = len(target) yield target[:] for m in range(1, n + 1): for pattern in generate_pat(target, n, m): yield pattern def generate_pat(target, n, m): for idxs in itertools.combinations(range(n), m): pattern = target[:] for idx in idxs: pattern[idx] = '?' yield pattern print(solve(S))