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