#!/bin/python3 import sys import string as str h = [int(h_temp) for h_temp in input().strip().split(' ')] word = input().strip() m = 0 for i in word: n = str.ascii_lowercase.index(i) t = h[n] if t > m: m = t print(m*len(word))