#!/bin/python import sys h = map(int,raw_input().strip().split(' ')) word = raw_input().strip() max = 0 for letter in word: if h[ord(letter) - 97] > max: max = h[ord(letter) - 97] print(word.__len__()*max)