#!/bin/python import sys def l_to_idx(l): return ord(l) - ord('a') h = map(int,raw_input().strip().split(' ')) word = raw_input().strip() width = len(word) max_h = 0 for letter in list(word): height = h[l_to_idx(letter)] if height > max_h: max_h = height area = width * max_h print area