#!/bin/python3 import sys def he(l, h): return h[ord(l)-97] h = [int(h_temp) for h_temp in input().strip().split(' ')] word = input().strip() ha = lambda x: he(x, h) maxh = max(list(map(ha, list(word)))) print(len(word)*maxh)