h = map(int,raw_input().strip().split(' ')) word = raw_input().strip() m=0; for i in word: if h[ord(i)-97]>m: m= h[ord(i)-97] print m*len(word)