#!/bin/python import sys h = map(int,raw_input().strip().split(' ')) word = raw_input().strip() max=0 for letter in word: current=h[ord(letter)-ord('a')] if current>max: max=current print len(word)*max