#!/bin/python import sys import string h = map(int,raw_input().strip().split(' ')) word = raw_input().strip() alphabet = list(string.ascii_lowercase) height_dict = dict(zip(alphabet, h)) max = 1 for letter in word: if height_dict[letter] > max: max = height_dict[letter] print max * len(word)