import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines R,G,B = readlines() def f(R): if R == b'NONE\n': return 16 return 15 - R.count(b',') x = f(R) * f(G) * f(B) answer = x * x print(answer)