第一题 n, m = map(int, input().split()) dp = [-1] * (m + 1) for j in range(m + 1): dp[j] = -1 dp[0] = 0 for i in range(1, n + 1): s = input() if s == "b": type = int(input()) t = dp[type] dp[type] = max(dp[0], dp[type]) else: type, v = map(int, input().split()) if dp[type] != -1: dp[0] = max(dp[0], dp[type] + v) res = max(dp) print(res)