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