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