#!/bin/python3 import sys h = [int(h_temp) for h_temp in input().strip().split(' ')] word = input().strip() x = 0 for i in word: if h[ord(i)-97] > x: x = h[ord(i)-97] a = len(word) * x print(a)