l=map(int,raw_input().split()) s=raw_input() h=0 for i in s: h=max(h,l[ord(i)-ord('a')]) print h*len(s)