#!/bin/python3

import sys


h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()

print(max([h[ord(c) - 97] for c in word])*len(word))