#!/bin/python import sys h = map(int,raw_input().strip().split(' ')) word = raw_input().strip() #area=1 n=len(word) height=0 for i in word: if h[ord(i)-ord('a')]>height: height=h[ord(i)-ord('a')] print height*n