#!/bin/python import sys h = map(int,raw_input().strip().split(' ')) word = raw_input().strip() letters = 'a b c d e f g h i j k l m n o p q r s t u v w x y z'.split(' ') let_dict = {} for i, l in enumerate(letters): let_dict[l] = i max_height = 0 for i in word: if max_height < h[let_dict[i]]: max_height = h[let_dict[i]] print max_height * len(word)