def solve(): h = list(map(int, input().split())) s = input() highest = 0 for x in s: highest = max(highest, h[ord(x) - 97]) print(len(s) * highest) def main(): solve() if __name__ == '__main__': main()