my_length = map(int,raw_input().split(' ')) my_str = list(raw_input()) temp = [] for item in my_str: temp.append(my_length[ord(item)-97]) print max(temp)*len(my_str)