#!/bin/python3 import sys import string ab = list(string.ascii_lowercase) h = [int(h_temp) for h_temp in input().strip().split(' ')] word = input().strip() mapping = list(zip(ab, h)) max_height = 0 for letter in word: height = 0 for abh in mapping: if abh[0] == letter: height = abh[1] max_height = max(height, max_height) print(str(len(word) * max_height))