#!/bin/python import sys h = map(int,raw_input().strip().split(' ')) word = raw_input().strip() width = len(word) height = 0 for l in word: height = max(height, h[ord(l) - 97]) print width * height