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