#map(int,raw_input().split()) t = map(int,raw_input().split()) s = raw_input() print len(s)*max(t[ord(x)-ord('a')] for x in s)