#!/bin/python import sys import string al = list(string.ascii_lowercase) h = map(int,raw_input().strip().split(' ')) di = dict(zip(al,h)) word = raw_input().strip() res= max([di[x] for x in word]) * len(word) print res