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