#The solution in Python3 is as follows:
a=list(map(int,input().split()))
s=input()
b=[]
alfa = "abcdefghijklmnopqrstuvwxyz"
rdict = dict([ (x[1],x[0]) for x in enumerate(alfa) ])
for i in s:
b.append(a[rdict[i]])
print(len(b)*max(b))
#Keep visiting for more solutions of HackerRank problems in Python 3.Thank you!!!