#!/bin/python import sys h = map(int,raw_input().strip().split(' ')) word = raw_input().strip() m = {} i = 0 for l in 'abcdefghijklmnopqrstuvwxyz': m[l] = h[i] i += 1 width = len(word) max = 1 for letter in word: if m[letter] > max: max = m[letter] print max * width