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