def cnt(str): if(str[0]=="NONE"): return 0 else: return len(str) r = 16 - cnt(input().split(",")) g = 16 - cnt(input().split(",")) b = 16 - cnt(input().split(",")) print(r**2 * g**2 * b**2)