h=map(int,raw_input().split()) words=raw_input().split() res=0 for word in words: H=max([h[ord(x)-97] for x in list(word)]) res+=len(word)*H print res