human
DZY loves collecting special strings which only contain lowercase letters. For each lowercase letter c DZY knows its value wc. For each special string s = s1s2... s|s| (|s| is the length of the string) he represents its value with a function f(s), where 


Now DZY has a string s. He wants to insert k lowercase letters into this string in order to get the largest possible value of the resulting string. Can you help him calculate the largest possible value he could get? 

Input

The first line contains a single string s (1 ≤ |s| ≤ 103).

The second line contains a single integer k (0 ≤ k ≤ 103).

The third line contains twenty-six integers from wa to wz. Each such number is non-negative and doesn't exceed 1000.

Output

Print a single integer — the largest possible value of the resulting string DZY could get.

Examples

Input

abc
3
1 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

Output

41

Note

In the test sample DZY can obtain "abcbbc", value = 1·1 + 2·2 + 3·2 + 4·2 + 5·2 + 6·2 = 41.
Using python can you solve the prior task?
 ... Give me a Python program to print a single integer — the largest possible value of the resulting string DZY could get?
assistant
#Here is Python program to print a single integer — the largest possible value of the resulting string DZY could get.

# coding: utf-8
from sys import stdin
from sys import stdout

class Alphabet(object):

    start_count = ord('a')

    def __init__(self, cost_string):
        self._alphabet = {chr(i): int(cost) for i, cost
                          in enumerate(cost_string.split(' '),
                                       start=self.start_count)}
        
    def __len__(self):
       return 26

    def __getitem__(self, letter):
        return self._alphabet.get(letter, 0)

    @property
    def max(self):
        return max(self._alphabet.values())

def cost(in_str, alphabet, start=1):
    cost = 0
    for i, letter in enumerate(in_str, start=start):
        cost += alphabet[letter] * i
    return cost

def insert_cost(cost, start, count):
	return sum([i*cost for i in xrange(start, start+count)])

if __name__ == '__main__':

    in_str = stdin.readline()
    insert_count = stdin.readline()
    cost_string = stdin.readline()

    in_str = in_str.strip()
    insert_count = int(insert_count)
    alphabet = Alphabet(cost_string)

    string_cost = cost(in_str, alphabet)
    out_int = string_cost + insert_cost(alphabet.max, len(in_str)+1, insert_count)

    print out_int