import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np S = read().rstrip().decode() dp = np.full((21, 21, 21, 21), -100, np.int32) dp[0, 0, 0, 0] = 0 for x in S: newdp = dp.copy() if x in 'K?': np.maximum(newdp[1:], dp[:-1], out=newdp[1:]) if x in 'U?': np.maximum(newdp[:-1, 1:], dp[1:, :-1], out=newdp[:-1, 1:]) if x in 'R?': np.maximum(newdp[:, :-1, 1:], dp[:, 1:, :-1], out=newdp[:, :-1, 1:]) if x in 'O?': np.maximum(newdp[:, :, :-1, 1:], dp[:, :, 1:, :-1], out=newdp[:, :, :-1, 1:]) if x in 'I?': np.maximum(newdp[:, :, :, :-1], dp[:, :, :, 1:] + 1, out=newdp[:, :, :, :-1]) dp = newdp print(dp.max())