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