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