#!/bin/python3 import sys h = [int(h_temp) for h_temp in input().strip().split(' ')] word = [ord(ch) - 97 for ch in input().strip()] width = len(word) height = 0 for letter in word: height = max(height, h[letter]) print(height * width)