r = list(input().split(",")) g = list(input().split(",")) b = list(input().split(",")) if r[0] == "NONE": rr = 0 else: rr = len(r) if g[0] == "NONE": gg = 0 else: gg = len(g) if b[0] == "NONE": bb = 0 else: bb = len(b) print(((16-rr)*(16-gg)*(16-bb))**2)