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