#!/bin/python3 import sys h = [int(h_temp) for h_temp in input().strip().split(' ')] word = input().strip() n=len(word) cur=0 for char in word: idx=ord(char)-ord('a') cur=max(h[idx],cur) print(cur*n)