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