#!/bin/python import sys h = map(int,raw_input().strip().split(' ')) word = raw_input().strip() c_h = [h[ord(c)-ord('a')] for c in word] print len(word)*max(c_h)