import math, re, sys print(sum(math.prod(max(int(n) for n in re.findall(f"[0-9]+(?= {color})", line)) for color in ("red", "green", "blue")) for line in open("input.txt", "rt").readlines()))