h = [int(x) for x in input().strip().split()] w = [ord(x) - ord('a') for x in input().strip()] max_height = 0 for x in w: max_height = max(max_height, h[x]) pass area = max_height * len(w) print(area)