#!/bin/python import sys def get_selection_area(word, h): max_height = -float('inf') for c in word.lower(): max_height = max(max_height, h[ord(c)-97]) return max_height * len(word) h = map(int,raw_input().strip().split(' ')) word = raw_input().strip() print get_selection_area(word, h)