h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()

max = 0
for c in word:
    if h[ord(c) - ord('a')] > max:
        max = h[ord(c) - ord('a')]

print(max * len(word))