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