13309 - How much is the string worth 2   

Description

In this problem, the first line of input contains a string C, we define C1 worth 1 coin, C2  worth 2 coins, C3 worth 3 coins ...., C26 worth 26 coins, other charactor worth 0 coin.
Now we have some lines of string (may contain spaces), you need to write a program to calculate how much each line is worth until S0 or end.

Hint:
0_ or _0 ( _ = space) worth 0, not the end of input

Input

The first line contains a string C, Ci worth i coins

The next lines, each line contains a string (may contain spaces)

Testcases:

(4/7) C = abcdefghijklmnopqrstuvwxyz, 0 <=  |S| <= 100, S  end

(1/7) C = abcdefghijklmnopqrstuvwxyz, 0 <=  |S| <= 100

(1/7) C = the permutaion of a ~ z, 0 <=  |S| <= 100S  end

(1/7) C = the permutaion of a ~ z, 0 <=  |S| <= 100

Output

Output the value of each line of string until S = 0 or end.

Sample Input  Download

Sample Output  Download

Tags




Discuss