R, G, B = [[i for i in input().strip().split(',')] for _ in range(3)] tmp = list('0123456789ABCDEF') R = len(set(tmp) - set(R)) ** 2 G = len(set(tmp) - set(G)) ** 2 B = len(set(tmp) - set(B)) ** 2 print(R * G * B)