#!/bin/python3 import sys h = [int(h_temp) for h_temp in input().strip().split(' ')] word = input().strip() width = len(word) max_height = 0 for i in range(0, width): j = ord(word[i]) - ord('a') if max_height < h[j]: max_height = h[j] print(width * max_height)