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