heights = [int(x) for x in input().split()] word = input().strip() height = max([heights[ord(c)-ord('a')] for c in word]) print(height*len(word))