#!/bin/python import sys h = map(int,raw_input().strip().split(' ')) word = raw_input().strip() alphabet = dict() for i,letter in enumerate('a b c d e f g h i j k l m n o p q r s t u v w x y z'.split()): alphabet[letter] = i max_height = 0 for letters in word: if h[alphabet[letters]] > max_height: max_height = h[alphabet[letters]] print max_height * len(word)