#!/bin/python3 import sys h = [int(h_temp) for h_temp in input().strip().split(' ')] word = input().strip() word_hs = map(lambda x : h[ord(x)-ord('a')], word) print(len(word) * max(word_hs))