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