#!/bin/python3 import sys h = [int(h_temp) for h_temp in input().strip().split(' ')] S = input().strip() l=len(S) b=1 for s in S: b=max(b,h[ord(s)-ord('a')]) print(l*b)