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