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