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.
 ... Write me a Python code to print a single integer — the largest possible value of the resulting string DZY could get?
assistant
#Here is Python code to print a single integer — the largest possible value of the resulting string DZY could get.

class CodeforcesTask447BSolution:
    def __init__(self):
        self.result = ''
        self.string = ''
        self.k = 0
        self.values = []

    def read_input(self):
        self.string = input()
        self.k = int(input())
        self.values = [int(x) for x in input().split(" ")]

    def process_task(self):
        values = {}
        alphabet = "abcdefghijklmnopqrstuvwxyz"
        for x in range(len(alphabet)):
            values[alphabet[x]] = self.values[x]
        total_value = 0
        mx_val = max(self.values)
        for i in range(len(self.string)):
            total_value += (i + 1) * values[self.string[i]]
        for i in range(len(self.string), len(self.string) + self.k):
            total_value += (i + 1) * mx_val
        self.result = str(total_value)

    def get_result(self):
        return self.result

if __name__ == "__main__":
    Solution = CodeforcesTask447BSolution()
    Solution.read_input()
    Solution.process_task()
    print(Solution.get_result())