#!/bin/python3 import sys h = [int(h_temp) for h_temp in input().strip().split(' ')] word = input().strip() mx = h[0] n = len(word) for i in range(n): id = ord(word[i])-ord('a') mx = max(mx,h[id]) mx = mx*len(word) print(mx)