When a contiguous block of text is selected in a PDF viewer, the selection is highlighted with a blue rectangle. In this PDF viewer, each word is highlighted independently. For example: 

There is a list of $26$ character heights aligned by index to their letters.  For example, 'a' is at index $0$ and 'z' is at index $25$.  There will also be a string.  Using the letter heights given, determine the area of the rectangle highlight in $\textit{mm}^2$ assuming all letters are $1mm$ wide.  

Example 

$h=[1,3,1,3,1,4,1,3,2,5,5,5,1,1,1,5,5,1,5,2,5,5,5,5,5,5]$
$word='\ \textit{torn}'$

The heights are $t=2,o=1,r=1$ and $n=1$.  The tallest letter is $2$ high and there are $4$ letters.  The hightlighted area will be $2*4=8mm^{2}$ so the answer is $8$.  

Function Description  

Complete the designerPdfViewer function in the editor below.  

designerPdfViewer has the following parameter(s):

int h[26]: the heights of each letter  
string word: a string  

Returns  

int: the size of the highlighted area  

Input Format

The first line contains $26$ space-separated integers describing the respective heights of each consecutive lowercase English letter, ascii[a-z]. 

The second line contains a single word consisting of lowercase English alphabetic letters.

Constraints

$1\leq h[?]\leq7$, where $\mbox{?}$ is an English lowercase letter.
$word$ contains no more than $10$ letters.   

Sample Input 0
1 3 1 3 1 4 1 3 2 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
abc

Sample Output 0
9

Explanation 0

We are highlighting the word abc:

Letter heights are $\boldsymbol{a}=1$, $b=3$ and $\boldsymbol{c=1}$. The tallest letter, b, is $3mm$ high. The selection area for this word is $3\cdot1mm\cdot3mm=9mm^2$.

Note: Recall that the width of each character is $1mm$.

Sample Input 1
1 3 1 3 1 4 1 3 2 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 7
zaba

Sample Output 1
28

Explanation 1

The tallest letter in $zaba$ is $z$ at $7mm$. The selection area for this word is $4\times1mm\times7mm=28mm^2$.

Source: hackerrank | Difficulty: EASY
Tags: Implementation


Solutions:
import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
print(len(word) * max((h[ord(l) - ord('a')] for l in word)))


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
print(len(word) * max(map(lambda x: h[ord(x) - ord('a')], word)))


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
print(max([h[ord(c) - 97] for c in word]) * len(word))


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
len_word = len(word)
word_heights = [h[ord(letter) - ord('a')] for letter in word]
print(len_word * max(word_heights))


h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
max = 0
for c in word:
	if h[ord(c) - ord('a')] > max:
		max = h[ord(c) - ord('a')]
print(max * len(word))


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
alpha = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
max_height = max([h[i] for i in range(26) if alpha[i] in word])
print(len(word) * max_height)


def solve():
	h = list(map(int, input().split()))
	s = input()
	highest = 0
	for x in s:
		highest = max(highest, h[ord(x) - 97])
	print(len(s) * highest)

def main():
	solve()
main()


h = [int(x) for x in input().strip().split()]
w = [ord(x) - ord('a') for x in input().strip()]
max_height = 0
for x in w:
	max_height = max(max_height, h[x])
	pass
area = max_height * len(w)
print(area)


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
max_height = 0
for i in range(len(word)):
	num = ord(word[i]) - 97
	if h[num] >= max_height:
		max_height = h[num]
area = len(word) * max_height
print(area)


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
x = 0
for i in word:
	if h[ord(i) - 97] > x:
		x = h[ord(i) - 97]
a = len(word) * x
print(a)


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
S = input().strip()
l = len(S)
b = 1
for s in S:
	b = max(b, h[ord(s) - ord('a')])
print(l * b)


import sys
import string
ab = list(string.ascii_lowercase)
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
mapping = list(zip(ab, h))
max_height = 0
for letter in word:
	height = 0
	for abh in mapping:
		if abh[0] == letter:
			height = abh[1]
	max_height = max(height, max_height)
print(str(len(word) * max_height))


import sys

def he(l, h):
	return h[ord(l) - 97]
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
ha = lambda x: he(x, h)
maxh = max(list(map(ha, list(word))))
print(len(word) * maxh)


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
mx = h[0]
n = len(word)
for i in range(n):
	id = ord(word[i]) - ord('a')
	mx = max(mx, h[id])
mx = mx * len(word)
print(mx)


import sys
from string import ascii_lowercase as keys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
print(len(word) * max((h[keys.index(w)] for w in word)))


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
heights = []
for each in word:
	val = ord(each)
	heights.append(h[val - 97])
print(max(heights) * len(word))


import sys
sys.setrecursionlimit(30000)
from collections import Counter, defaultdict, deque
from math import ceil, floor, factorial, fsum, isinf, exp, log, log10, log2, isfinite, sqrt
from math import pi as PI, e as E
from math import sin, cos, tan, sinh, cosh, tanh, asin, acos, atan
from fractions import Fraction
from itertools import starmap, tee, chain, filterfalse, combinations as combos
from itertools import permutations as perms, product as prod, combinations_with_replacement as rcombos
from functools import reduce, partial
import operator as ops
from operator import __not__ as notit
from operator import __abs__ as absit
from operator import __or__ as orit
(PHI, PHI2) = ((1 + 5 ** 0.5) / 2, (5 ** 0.5 - 1) / 2)
INF = float('inf')

class TreeNode:

	def __init__(self, v):
		self.val = v
		self.left = None
		self.right = None

def setBit(x, offset):
	return x | 1 << offset

def clearBit(x, offset):
	return x & ~(1 << offset)

def getBit(x, offset):
	return 1 if testBit(x, offset) > 0 else 0

def testBit(x, offset):
	return x & 1 << offset

def flipBitAt(x, offset):
	return x ^ 1 << offset

def flipBits(x, length=-1):
	length = x.bit_length() - 1 if length == -1 else length
	return x ^ (1 << length) - 1

def numBits(x):
	return x.bit_length()

def countOnes(x):
	return bin(x).count('1')

def countZeros(x, length=-1):
	length = x.bit_length() if length == -1 else length
	return length - countOnes(x)

def getList(tcast=str):
	return [tcast(x) for x in input().strip().split(' ')]

def getItems(*tcast):
	return map(lambda f, x: f(x), tcast, getList())

def getVal(tcast=str):
	return tcast(input().strip())

def getMatrix(r, tcast=str):
	return [getList(tcast) for row in range(r)]

def isOdd(n):
	return n & 1 > 0

def isEven(n):
	return not n & 1

def numDigits(n):
	return len(str(n)) - (1 if n < 0 else 0)

def getRecip(f):
	return Fraction(f.denominator, f.numerator)

def _gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def gcd(*xs):
	nums = xs[0] if type(xs[0]) == list else list(xs)
	cur = nums[0]
	for n in nums[1:]:
		if cur == 1:
			return cur
		cur = _gcd(cur, n)
	return cur

def _lcm(a, b):
	return a // gcd(a, b) * b

def lcm(*xs):
	nums = xs[0] if type(xs[0]) == list else list(xs)
	cur = nums[0]
	for n in nums[1:]:
		cur = _lcm(cur, n)
	return cur

def primesUpto(n):
	isp = [True] * (n + 1)
	(isp[0], isp[1]) = (False, False)
	primes = []
	for (i, x) in enumerate(isp):
		if x:
			primes.append(i)
			mults = i * i
			while mults <= n:
				isp[mults] = False
				mults += i
	return primes

def primeFactor(n):
	factors = Counter()
	while not n & 1:
		factors[2] += 1
		n >>= 1
	trynum = 3
	while trynum <= ceil(sqrt(n)):
		while n % trynum == 0:
			factors[trynum] += 1
			n //= trynum
		trynum += 2
	if n != 1:
		factors[n] += 1
	return factors

def isPrime(n):
	if n & 1 and n >= 2:
		trynum = 3
		limit = ceil(sqrt(n))
		while trynum < limit:
			if n % trynum == 0:
				return False
			trynum += 2
		else:
			return True
	else:
		return False

def nthFib(n):
	if n <= 2:
		return 1
	else:
		(a, b) = (1, 1)
		while n > 2:
			(a, b) = (b, a + b)
			n -= 1
		return b

def zipNWith(f, *x):
	return (f(y) for y in zip(*x))

def zipWith(f, xs, ys):
	return (f(x, y) for (x, y) in zip(xs, ys))

def flatten(xs):
	return reduce(ops.concat, xs)

def quantify(pred, it):
	return sum(map(pred, it))

def dotproduct(xs, ys):
	return sum(map(ops.mul, xs, ys))

def pairwise(it):
	(a, b) = tee(it)
	next(b, None)
	return zip(a, b)

def bipartition(pred, it):
	(t, f) = tee(it)
	return (filter(pred, t), filterfalse(pred, f))

def powerset(it):
	s = list(it)
	return chain.from_iterable((combos(s, r) for r in range(len(s) + 1)))

def alphatonum(c):
	return ord(c) - ord('a')
heights = getList(int)
word = getVal(str)
whs = map(lambda x: heights[alphatonum(x)], word)
maxh = max(whs)
width = len(word)
print(maxh * width)


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
n = len(word)
cur = 0
for char in word:
	idx = ord(char) - ord('a')
	cur = max(h[idx], cur)
print(cur * n)


import sys
import string
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
w_len = len(word)
st = string.ascii_lowercase
max_h = 0
for ch in word:
	i = st.index(ch)
	max_h = max(max_h, h[i])
ans = max_h * w_len
print(ans)


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
maxi = 0
for c in word:
	if maxi < h[ord(c) - 97]:
		maxi = h[ord(c) - 97]
print(maxi * len(word))


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
word_hs = map(lambda x: h[ord(x) - ord('a')], word)
print(len(word) * max(word_hs))


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
mx = -1
for i in range(len(word)):
	if h[ord(word[i]) - 97] > mx:
		mx = h[ord(word[i]) - 97]
print(mx * len(word))


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
hmax = max([h[ord(hi) - ord('a')] for hi in word])
print(hmax * len(word))


h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
l = 0
m = 0
for i in word:
	l += 1
	if h[ord(i) - 97] > m:
		m = h[ord(i) - 97]
print(l * m)


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
heights = [h[ord(x) - 97] for x in word]
print(len(word) * max(heights))


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
width = len(word)
max_height = 0
for i in range(0, width):
	j = ord(word[i]) - ord('a')
	if max_height < h[j]:
		max_height = h[j]
print(width * max_height)


heights = [int(x) for x in input().split()]
word = input().strip()
height = max([heights[ord(c) - ord('a')] for c in word])
print(height * len(word))


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = [ord(ch) - 97 for ch in input().strip()]
width = len(word)
height = 0
for letter in word:
	height = max(height, h[letter])
print(height * width)


a = list(map(int, input().strip().split()))
s = input().strip()
l = len(s)
m = 0
for i in range(l):
	if a[ord(s[i]) - 97] >= m:
		m = a[ord(s[i]) - 97]
print(m * l)


a = list(map(int, input().split()))
s = input()
letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
m = 0
for i in range(len(letters)):
	if letters[i] in s:
		m = max(m, a[i])
print(len(s) * m)


import sys
import string as str
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
m = 0
for i in word:
	n = str.ascii_lowercase.index(i)
	t = h[n]
	if t > m:
		m = t
print(m * len(word))


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
hw = []
for x in word:
	hw.append(h[ord(x) - 97])
count = max(hw) * len(word) * 1
print(count)


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
b = list('abcdefghijklmnopqrstuvwxyz')
hashy = {}
for i in range(len(b)):
	if b[i] not in hashy:
		hashy[b[i]] = h[i]
word = list(input().strip())
length = len(word)
maximum = 0
for w in word:
	if w in hashy:
		if hashy[w] > maximum:
			maximum = hashy[w]
print(maximum * length)


import sys
w = 1
hv = [int(x) for x in input().strip().split()]
h = {}
for c in list('abcdefghijklmnopqrstuvwxyz'):
	h[c] = hv.pop(0)
text = list(input().strip())
wh = 0
ww = 0
for c in text:
	wh = max(h[c], wh)
	ww += w
print(wh * ww)


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
ans = len(word)
a = 0
for i in word:
	a = max(a, h[ord(i) - 97])
print(a * ans)


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
letterIndex = {}
index = 0
for char in 'abcdefghijklmnopqrstuvwxyz':
	letterIndex[char] = index
	index += 1
length = len(word)
maxHeight = 0
for char in word:
	maxHeight = max(maxHeight, h[letterIndex.get(char)])
print(length * maxHeight)


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
m = 0
for i in range(len(word)):
	if h[ord(word[i]) - 97] > m:
		m = h[ord(word[i]) - 97]
print(m * len(word))


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
x = []
ws = len(word)
for i in range(ws):
	x.append(h[ord(word[i]) - 97])
print(max(x) * ws)


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
print(len(word) * max([h[ord(i) - ord('a')] for i in word]))


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
sum = 0
ma = []
for i in word:
	ma += [h[ord(i) - ord('a')]]
print(len(word) * max(ma))


price = list(map(int, input().split()))
word = input()
print(len(word) * max((price[ord(letter) - 97] for letter in word)))


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = list(input())
hi = 0
tall = -1
for i in range(len(word)):
	if h[ord(word[i]) - 97] > hi:
		hi = h[ord(word[i]) - 97]
print(len(word) * hi)


import sys
x = 'abcdefghijklmnopqrstuvwxyz'
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
t = []
for i in word:
	t.append(h[x.index(i)])
print(max(t) * len(word))


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
height = 0
for c in word:
	height = max(height, h[ord(c) - ord('a')])
print(height * len(word))


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
letters = list(map(chr, range(97, 123)))
key_index_map = {}
for ind in range(len(h)):
	key_index_map[letters[ind]] = h[ind]
heights = []
for each in word:
	heights.append(key_index_map[each])
max_height = max(heights)
print(max_height * len(word))


a = list(map(int, input().split()))
d = {}
k = 97
for i in a:
	d[chr(k)] = i
	k += 1
x = list(input())
maxx = 0
for i in x:
	if d[i] > maxx:
		maxx = d[i]
print(len(x) * maxx)


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = ''.join(input().split())
offset = ord('a')
height = 0
width = 0
for char in word:
	width += 1
	temp = h[ord(char) - offset]
	if temp > height:
		height = temp
print(height * width)


heights = [int(n) for n in input().split()]
words = [str(n) for n in input().split()]
total = 0
for word in words:
	maxHeight = 0
	for n in range(len(word)):
		if heights[ord(word[n]) - 97] > maxHeight:
			maxHeight = heights[ord(word[n]) - 97]
	total += len(word) * maxHeight
print(total)


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
wordint = []
for letter in word:
	wordint.append(h[ord(letter) - 97])
print(max(wordint) * len(word))


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
maxh = 0
for c in word:
	if h[ord(c) - 97] > maxh:
		maxh = h[ord(c) - 97]
print(maxh * len(word))


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
print(len(word) * max([h[ord(c) - ord('a')] for c in word]))


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
maxh = 0
for c in word:
	height = h[ord(c) - ord('a')]
	if height > maxh:
		maxh = height
print(maxh * len(word))


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
indexes = [ord(c) - 97 for c in word]
maxHeight = 0
for i in indexes:
	maxHeight = h[i] if h[i] > maxHeight else maxHeight
print(maxHeight * len(indexes))


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
a = 'abcdefghijklmnopqrstuvwxyz'
lets = []
for each in word:
	lets.append(h[a.find(each)])
print(len(word) * max(lets))


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
li = []
max_num = 0
word = list(word)
for i in word:
	li = li + [ord(i) - 97]
for i in li:
	if h[i] > max_num:
		max_num = h[i]
area = len(word) * max_num
print(area)


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
heights = []
for char in word:
	heights.append(h[ord(char) - ord('a')])
print(max(heights) * len(word))


hight = [int(i) for i in input().split(' ')]
alphabet = 'abcdefghijklmnopqrstuvwxyz'
string = input()
index = [alphabet.index(i) for i in string]
t = [hight[i] for i in index]
print(max(t) * len(string))


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
max_h = 1
for i in word:
	if h[ord(i) - 97] > max_h:
		max_h = h[ord(i) - 97]
print(max_h * len(word))


import sys

def ans():
	mx = 0
	for c in word:
		ht = H[ord(c) - 97]
		if ht > mx:
			mx = ht
	return len(word) * mx
H = list(map(int, input().strip().split(' ')))
word = input().strip()
print(ans())


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
mx = 0
for c in word:
	mx = max(h[ord(c) - ord('a')], mx)
print(mx * len(word))


import sys
import string
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
w = len(word)
s = string.ascii_lowercase
h = max([h[s.find(c)] for c in word])
print(h * w)


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
alphabet = 'abcdefghijklmnopqrstuvwxyz'
table = dict()
for i in range(len(alphabet)):
	table[alphabet[i]] = i
currMax = 0
for letter in word:
	temp = h[table[letter]]
	if temp > currMax:
		currMax = temp
print(currMax * len(word))


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
a = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
d = {}
for x in range(len(a)):
	d[a[x]] = h[x]
word = input().strip()
m = 1
for y in word:
	if d[y] > m:
		m = d[y]
area = len(word) * m
print(area)


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
mx = 0
cnt = len(word)
for i in range(cnt):
	ch = ord(word[i]) - ord('a')
	mx = max(mx, h[ch])
print(mx * cnt)


h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
width = len(word)
max = 0
for i in word:
	asc = ord(i) - 97
	if max < h[asc]:
		max = h[asc]
area = max * width
print(area)


heights = [int(x) for x in input().split()]
word = input()
height = [heights[ord(letter) - 97] for letter in word]
tallest = max(height)
print(len(word) * tallest)


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
a = list('abcdefghijklmnopqrstuvwxyz')
word = input().strip()
maxh = 0
for i in word:
	t = h[a.index(i)]
	if t > maxh:
		maxh = t
print(len(word) * maxh)


import sys
alph = [int(arr_temp) for arr_temp in input().strip().split(' ')]
word = input().strip()
largest = 0
for i in word:
	x = ord(i) - 97
	if largest < alph[x]:
		largest = alph[x]
print(largest * len(word))


import sys
high = 0
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
for i in word:
	l = h[ord(i) - 97]
	if l > high:
		high = l
print(high * len(word))


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = list(input().strip().lower())
ascii_char = [h[ord(i) - 97] for i in word]
print(len(word) * max(ascii_char))


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
h1 = 1
for i in word:
	if h[ord(i) - 97] > h1:
		h1 = h[ord(i) - 97]
print(h1 * len(word))


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
maxHeight = -1
for x in word:
	pos = ord(x) - 97
	maxHeight = max(maxHeight, h[pos])
print(maxHeight * len(word))


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
height = []
for i in word:
	height += [h[ord(i) % 97]]
maxheight = max(height)
width = len(word)
print(maxheight * width)


from string import ascii_lowercase as alph
arr = [int(i) for i in input().split()]
s = input()
heights = [arr[alph.index(i)] for i in s]
print(max(heights) * len(s))


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
maxh = 0
for w in word:
	ind = ord(w) - 97
	if h[ind] > maxh:
		maxh = h[ind]
print(1 * maxh * len(word))


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
maximum = h[ord(word[0]) - 97]
for i in range(1, len(word)):
	if h[ord(word[i]) - 97] > maximum:
		maximum = h[ord(word[i]) - 97]
print(maximum * len(word))


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
ans = 0
m = 0
for letter in word:
	if m < h[ord(letter) - 97]:
		m = h[ord(letter) - 97]
ans = len(word) * m
print(ans)


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
max = 0
for i in range(0, len(word)):
	letter = word[i]
	asc = ord(letter)
	if max < h[asc - 97]:
		max = h[asc - 97]
print(len(word) * max)


import sys
alphabet = 'abcdefghijklmnopqrstuvwxyz'
h = list(map(int, input().strip().split()))
word = input().strip()
heights = []
for char in word:
	heights.append(h[alphabet.index(char)])
print(max(heights) * len(heights))


h = {chr(i + 97): int(x) for (i, x) in enumerate(input().strip().split())}
word = input().strip()
maxh = 1
for char in word:
	maxh = max(maxh, h[char])
print(len(word) * maxh)


import sys
import string
alphabet = string.ascii_lowercase
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
myDict = {}
largest = 0
for x in range(len(alphabet)):
	myDict[alphabet[x]] = h[x]
for x in range(len(word)):
	if myDict[word[x]] > largest:
		largest = myDict[word[x]]
print(largest * len(word))


l = list(map(int, input().split()))
dict = {}
i = 0
for k in 'abcdefghijklmnopqrstuvwxyz':
	dict[k] = l[i]
	i += 1
s = input()
a = []
for j in s:
	a.append(dict[j])
m = max(a)
print(len(s) * m)


import sys
import string

def char_position(letter):
	return ord(letter) - 97
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
breite = len(word)
hoehe = 0
for i in range(breite):
	if hoehe < h[char_position(word[i])]:
		hoehe = h[char_position(word[i])]
result = breite * hoehe
print(result)


def method():
	li = [int(x) for x in input().strip().split(' ')]
	s = input()
	max_ht = 0
	for ch in s:
		if li[ord(ch) - 97] > max_ht:
			max_ht = li[ord(ch) - 97]
	area = len(s) * max_ht
	print(area)
method()


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
alphabet = 'abcdefghijklmnopqrstuvwxyz'
word = input().strip()

def highest_character(word):
	maxHeight = 0
	for x in word:
		if h[alphabet.index(x)] >= maxHeight:
			maxHeight = h[alphabet.index(x)]
	return maxHeight
print(highest_character(word) * len(word))


h = list(map(int, input().split()))
word = input()
maxHeight = h[0]
for each in word:
	if h[ord(each) - 97] > maxHeight:
		maxHeight = h[ord(each) - 97]
print(maxHeight * len(word))


import sys
l = []
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
for i in range(len(word)):
	l.append(h[ord(word[i]) - 97])
m = max(l)
print(m * len(word))


import sys

def char_position(letter):
	return ord(letter) - 97
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
maxHeight = 0
maxWidth = 0
for c in word:
	index = char_position(c)
	if h[index] > maxHeight:
		maxHeight = h[index]
	maxWidth += 1
print(maxHeight * maxWidth)


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
w = input().strip()
w = list(w)
max = 0
for x in w:
	if h[ord(x) - 97] > max:
		max = h[ord(x) - 97]
print(max * len(w))


import sys
from string import ascii_lowercase as al
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
dic = {x: h[i] for (i, x) in enumerate(al, 0)}
height = []
for w in word:
	height.append(dic[w])
print(len(word) * max(height))


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = list(input().strip())
highest = h[ord(word[0]) - 97]
for i in range(len(word)):
	if highest < h[ord(word[i]) - 97]:
		highest = h[ord(word[i]) - 97]
print(highest * len(word))


import sys
import string
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
a = {}
c = list(string.ascii_lowercase)
for i in range(0, 26):
	a[c[i]] = h[i]
d = []
for i in word:
	d.append(a[i])
print(int(max(d) * len(word)))


import sys
import string
a = string.ascii_lowercase
a = list(a)
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
w = len(word)
word = list(word)
lst = []
for i in range(len(word)):
	lst.append(h[a.index(word[i])])
print(max(lst) * w)


import sys
ss = 'abcdefghijklmnopqrstuvwxyz'
x = [int(y) for y in input().split()]
s = input()
mx = 0
for i in range(len(s)):
	for j in range(len(ss)):
		if s[i] == ss[j]:
			if mx < x[j]:
				mx = x[j]
print(mx * len(s))


import sys
import string
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
alphabet = string.ascii_lowercase
d = dict(zip(alphabet, h))
lst = []
for c in word:
	lst.append(d[c])
print(max(lst) * len(word))


n = list(map(int, input().split()))
s = input()
k = len(s)
max = 0
for i in range(k):
	if n[ord(s[i]) - 97] >= max:
		max = n[ord(s[i]) - 97]
print(k * max)


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
max = 0
for c in word:
	index = ord(c) - ord('a')
	if h[index] > max:
		max = h[index]
print(max * len(word))


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
l = 'abcdefghijklmnopqrstuvwxyz'
D = dict(zip(l, h))
mx = 0
for w in word:
	if D[w] > mx:
		mx = D[w]
print(mx * len(word))


import sys
h = [int(a_temp) for a_temp in input().strip().split(' ')]
letter = input().strip()
height = []
for i in range(0, len(letter)):
	aschi = ord(letter[i]) - 97
	height.append(h[aschi])
maxheight = max(height)
print(maxheight * len(letter))


import sys
h = [int(h_temp) for h_temp in input().strip().split(' ')]
word = input().strip()
word = word.lower()
mh = 0
b = []
b = sorted(word)
alpha = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
for i in range(len(b)):
	if b[i] in alpha:
		c = alpha.index(b[i])
		hei = h[c]
		if mh < hei:
			mh = hei
area = mh * len(b)
print(area)