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