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