#!/bin/python3 import sys h = [int(h_temp) for h_temp in input().strip().split(' ')] word = input().strip() mx = -1 for i in range(len(word)): if(h[ord(word[i])-97]>mx): mx = h[ord(word[i])-97] print(mx*len(word))