#!/bin/python letter_height = {chr(i+65): int(h) for i, h in enumerate(raw_input().strip().split(' '))} word = raw_input().strip() max_height = max(letter_height[ch.upper()] for ch in word) print len(word) * max_height