#!/bin/python3 import sys from string import ascii_lowercase as keys h = [int(h_temp) for h_temp in input().strip().split(' ')] word = input().strip() print(len(word) * max(h[keys.index(w)] for w in word))