#!/bin/python import sys a = ord('a') h = map(int,raw_input().strip().split(' ')) word = raw_input().strip() max_h = max(map(lambda c: h[ord(c) - a], word)) print max_h * len(word)