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