#include <bits/stdc++.h>
using namespace std;
int dx4[] = {0, 0, -1, 1};
int dy4[] = {1, -1, 0, 0};
int dx8[] = {1, 1, 1, 0, 0, -1, -1, -1};
int dy8[] = {1, 0, -1, 1, -1, 1, 0, -1};
const long long int INF = 1LL * (1e10);
const long long int MOD = 1LL * (1e9 + 7);
const int Size = 100010;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const double PII = 2 * acos(0.0);
inline bool isp(int x) {
  if (x < 2) return false;
  int sq = sqrt(x);
  for (int i = 2; i <= sq; i++) {
    if (x % i == 0) return false;
  }
  return true;
}
inline bool leap_year(int x) {
  if (((x % 4 == 0) && (x % 100 != 0)) || (x % 400 == 0)) return true;
  return false;
}
inline int power(int x, int y) {
  int ret = 1;
  for (int i = 1; i <= y; i++) {
    ret *= x;
  }
  return ret;
}
inline int st_int(string &str) {
  int num;
  stringstream st(str);
  st >> num;
  return num;
}
inline string int_st(int num) {
  string res;
  stringstream convert;
  convert << num;
  res = convert.str();
  return res;
}
vector<long long int> prime;
vector<bool> isprime(1000000, true);
inline void sieve() {
  isprime[0] = false;
  isprime[1] = false;
  isprime[2] = true;
  long long int sq = sqrt(1000000);
  for (long long int i = 2; i <= sq; i++) {
    if (isprime[i]) {
      for (long long int j = i; j * i < 1000000; j++) {
        isprime[i * j] = false;
      }
    }
  }
  for (long long int i = 2; i <= 1000000; i++) {
    if (isprime[i]) prime.push_back(i);
  }
}
int main(int argc, char const *argv[]) {
  ios_base ::sync_with_stdio(false);
  cin.tie(0);
  string str;
  cin >> str;
  map<char, int> M;
  long long int k, val;
  cin >> k;
  long long int mx = -1;
  for (int i = 0; i < 26; i++) {
    cin >> val;
    M['a' + i] = val;
    mx = max(mx, val);
  }
  long long int sum = 0;
  for (int i = 0; i < str.size(); i++) {
    sum += ((i + 1) * M[str[i]]);
  }
  if (k == 0) {
    cout << sum << '\n';
    return 0;
  }
  for (int i = str.size() + 1; i <= str.size() + k; i++) {
    sum += (i * mx);
  }
  cout << sum << '\n';
  return 0;
}

### Prompt

Your task is to create a CPP solution to the following problem:

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 

<image>

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.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int dx4[] = {0, 0, -1, 1};
int dy4[] = {1, -1, 0, 0};
int dx8[] = {1, 1, 1, 0, 0, -1, -1, -1};
int dy8[] = {1, 0, -1, 1, -1, 1, 0, -1};
const long long int INF = 1LL * (1e10);
const long long int MOD = 1LL * (1e9 + 7);
const int Size = 100010;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const double PII = 2 * acos(0.0);
inline bool isp(int x) {
  if (x < 2) return false;
  int sq = sqrt(x);
  for (int i = 2; i <= sq; i++) {
    if (x % i == 0) return false;
  }
  return true;
}
inline bool leap_year(int x) {
  if (((x % 4 == 0) && (x % 100 != 0)) || (x % 400 == 0)) return true;
  return false;
}
inline int power(int x, int y) {
  int ret = 1;
  for (int i = 1; i <= y; i++) {
    ret *= x;
  }
  return ret;
}
inline int st_int(string &str) {
  int num;
  stringstream st(str);
  st >> num;
  return num;
}
inline string int_st(int num) {
  string res;
  stringstream convert;
  convert << num;
  res = convert.str();
  return res;
}
vector<long long int> prime;
vector<bool> isprime(1000000, true);
inline void sieve() {
  isprime[0] = false;
  isprime[1] = false;
  isprime[2] = true;
  long long int sq = sqrt(1000000);
  for (long long int i = 2; i <= sq; i++) {
    if (isprime[i]) {
      for (long long int j = i; j * i < 1000000; j++) {
        isprime[i * j] = false;
      }
    }
  }
  for (long long int i = 2; i <= 1000000; i++) {
    if (isprime[i]) prime.push_back(i);
  }
}
int main(int argc, char const *argv[]) {
  ios_base ::sync_with_stdio(false);
  cin.tie(0);
  string str;
  cin >> str;
  map<char, int> M;
  long long int k, val;
  cin >> k;
  long long int mx = -1;
  for (int i = 0; i < 26; i++) {
    cin >> val;
    M['a' + i] = val;
    mx = max(mx, val);
  }
  long long int sum = 0;
  for (int i = 0; i < str.size(); i++) {
    sum += ((i + 1) * M[str[i]]);
  }
  if (k == 0) {
    cout << sum << '\n';
    return 0;
  }
  for (int i = str.size() + 1; i <= str.size() + k; i++) {
    sum += (i * mx);
  }
  cout << sum << '\n';
  return 0;
}

```