#!/bin/python import sys h = map(int,raw_input().strip().split(' ')) word = raw_input().strip() maxh = 0 for c in word: index = ord(c)-97 ht = h[index] if(ht>maxh): maxh = ht print len(word)*maxh