h = [int(h_temp) for h_temp in input().strip().split(' ')] word = list(map(str,input().strip())) word=[(ord(eve)%97) for eve in word] max=0 for ele in range(0,len(word)): if(h[ele]>max): max=h[ele] print(max*max)