#!/bin/python3 import sys h = [int(h_temp) for h_temp in input().strip().split(' ')] word = input().strip() len_word = len(word) word_heights = [h[ord(letter) - ord('a')] for letter in word] print(len_word*max(word_heights))