#!/bin/python import sys h = map(int,raw_input().strip().split(' ')) word = raw_input().strip() max_height = 0 len = 0 for letter in word: height = h[ord(letter) - ord('a')] if height > max_height: max_height = height len += 1 print max_height * len