#!/bin/python3 import sys h = [int(h_temp) for h_temp in input().strip().split(' ')] word = input().strip() maxi = 0 for c in word: if maxi < h[ord(c)-97]: maxi = h[ord(c)-97] print(maxi*len(word))