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