R = list(map(str, input().split(','))) G = list(map(str, input().split(','))) B = list(map(str, 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(r, g, b) print((16-r)**2*(16-g)**2*(16-b)**2)