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