#!/bin/python3 import sys h = [int(h_temp) for h_temp in input().strip().split(' ')] word = input().strip() heights = [] for each in word: val = ord(each) heights.append(h[val-97]) print(max(heights)*len(word))