#!/bin/python import sys h = map(int,raw_input().strip().split(' ')) word = raw_input().strip() maxLetterVal = -1 for letter in word: letterVal = h[ord(letter) - 97] if(letterVal > maxLetterVal): maxLetterVal = letterVal print len(word) * maxLetterVal