#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b);
long long lcm(long long a, long long b);
vector<long long> prime;
bitset<000000 + 1> isPrime;
vector<long long> primeFactor;
vector<long long> uniqueprimeFactor;
vector<long long> divisors[000000 + 1];
vector<long long> divNum;
long long phiValue[000000 + 1];
void seive(long long lim);
void primeFactorial(long long n);
void eulerPhi(long long lim);
void divGenerator(long long n);
void div(long long n);
long long bigMod(long long b, long long p, long long m);
long long nCr(long long n, long long r);
long long string2int(string str);
string int2string(long long num);
long long bs(long long arr[], long long l, long long r, long long x);
long long prevMatch(long long arr[], long long l, long long r, long long x);
long long range(long long arr[], long long l, long long r, long long left,
                long long right);
long long firstMarched(long long arr[], long long l, long long r, long long x);
long long vbs(vector<long long> arr, long long l, long long r, long long x);
long long vprevMatch(vector<long long> arr, long long l, long long r,
                     long long x);
long long vrange(vector<long long> arr, long long l, long long r,
                 long long left, long long right);
long long vfirstMarched(vector<long long> arr, long long l, long long r,
                        long long x);
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string str;
  cin >> str;
  long long k, a[26];
  cin >> k;
  long long mx = -1;
  for (long long i = 0; i < 26; ++i) {
    cin >> a[i];
    mx = max(mx, a[i]);
  }
  long long sum = 0;
  for (long long i = 0; i < (long long)str.size(); ++i) {
    sum = sum + (i + 1) * a[((int)(str[i]) - 97)];
  }
  for (long long i = (long long)str.size() + 1; k > 0; ++i) {
    sum = sum + i * mx;
    k--;
  }
  cout << sum << endl;
  return 0;
}
long long gcd(long long a, long long b) {
  if (a % b == 0) {
    return b;
  }
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
  long long ret = ((a / gcd(a, b)) * b);
  return ret;
}
void seive(long long lim) {
  isPrime.set();
  prime.push_back(2);
  for (long long i = 3; i <= lim; i += 2) {
    if (isPrime[i]) {
      prime.push_back(i);
      for (long long j = i * i; j <= lim; j += (i << 1)) {
        isPrime[j] = 0;
      }
    }
  }
}
void primeFactorial(long long n) {
  for (long long i = 0; prime[i] * prime[i] <= n; i++) {
    long long cnt = 0;
    while (n % prime[i] == 0) {
      n = n / prime[i];
      cnt++;
      primeFactor.push_back(prime[i]);
    }
    if (cnt > 0) {
      uniqueprimeFactor.push_back(prime[i]);
    }
    if (n == 1) {
      break;
    }
  }
  if (n > 1) {
    primeFactor.push_back(n);
    uniqueprimeFactor.push_back(n);
  }
}
void eulerPhi(long long lim) {
  for (long long i = 0; i <= lim; ++i) {
    phiValue[i] = i;
  }
  for (long long i = 2; i <= lim; ++i) {
    if (phiValue[i] == i) {
      for (long long j = i; j <= lim; j += i) {
        phiValue[j] = (phiValue[j] * (i - 1)) / i;
      }
    }
  }
  phiValue[0] = 1;
  phiValue[1] = 1;
}
long long bigMod(long long b, long long p, long long m) {
  long long y;
  if (b == 0) {
    return 0;
  }
  if (p == 0) {
    return 1;
  }
  if (p % 2 == 0) {
    y = bigMod(b, p / 2, m);
    y = (y * y) % m;
  } else {
    y = b % m;
    y = (y * bigMod(b, p - 1, m) % m) % m;
  }
  return (y + m) % m;
}
long long nCr(long long n, long long r) {
  long long p = 1, k = 1;
  if (n - r < r) {
    r = n - r;
  }
  if (r != 0) {
    while (r) {
      p *= n;
      k *= r;
      long long m = gcd(p, k);
      p /= m;
      k /= m;
      n--;
      r--;
    }
  } else {
    p = 1;
  }
  return p;
}
void divGenerator(long long n) {
  for (long long i = 1; i <= n; i++) {
    for (long long j = i; j <= n; j += i) {
      divisors[j].push_back(i);
    }
  }
}
long long string2int(string str) {
  long long cnt = 1, sum = 0;
  for (long long i = str.length() - 1; i >= 0; i--) {
    long long typcast = (int)(str[i]) - 48;
    sum = sum + typcast * cnt;
    cnt = cnt * 10;
  }
  return sum;
}
string int2string(long long num) {
  string str = "";
  while (num > 0) {
    int ch;
    ch = ((num) % 10) + 48;
    str += char(ch);
    num = num / 10;
  }
  reverse(str.begin(), str.end());
  return str;
}
void div(long long n) {
  for (long long i = 1; i * i <= n; ++i) {
    if (n % i == 0) {
      if (i != (n / i)) {
        divNum.push_back(i);
        divNum.push_back(n / i);
      } else {
        divNum.push_back(i);
      }
    }
  }
  sort(divNum.begin(), divNum.end());
}
long long bs(long long arr[], long long l, long long r, long long x) {
  long long m;
  while (l <= r) {
    m = (l + r) / 2;
    if (arr[m] == x) {
      return m;
    } else if (arr[m] < x) {
      l = m + 1;
    } else {
      r = m - 1;
    }
  }
  return -1;
}
long long vbs(vector<long long> arr, long long l, long long r, long long x) {
  long long m;
  while (l <= r) {
    m = (l + r) / 2;
    if (arr[m] == x) {
      return m;
    } else if (arr[m] < x) {
      l = m + 1;
    } else {
      r = m - 1;
    }
  }
  return -1;
}
long long prevMatch(long long arr[], long long l, long long r, long long x) {
  long long m, ret = -1;
  while (l <= r) {
    m = (l + r) / 2;
    if (arr[m] <= x) {
      ret = m;
      l = m + 1;
    } else {
      r = m - 1;
    }
  }
  return ret;
}
long long vprevMatch(vector<long long> arr, long long l, long long r,
                     long long x) {
  long long m, ret = -1;
  while (l <= r) {
    m = (l + r) / 2;
    if (arr[m] <= x) {
      ret = m;
      l = m + 1;
    } else {
      r = m - 1;
    }
  }
  return ret;
}
long long range(long long arr[], long long l, long long r, long long left,
                long long right) {
  long long ret;
  ret = prevMatch(arr, l, r, right) - prevMatch(arr, l, r, left - 1);
  return ret;
}
long long vrange(vector<long long> arr, long long l, long long r,
                 long long left, long long right) {
  long long ret;
  ret = vprevMatch(arr, l, r, right) - vprevMatch(arr, l, r, left - 1);
  return ret;
}
long long firstMarched(long long arr[], long long l, long long r, long long x) {
  long long m, ret = -1;
  while (l <= r) {
    m = (l + r) / 2;
    if (arr[m] == x) {
      ret = m;
      r = m - 1;
    } else if (arr[m] < x) {
      l = m + 1;
    } else {
      r = m - 1;
    }
  }
  return ret;
}
long long vfirstMarched(vector<long long> arr, long long l, long long r,
                        long long x) {
  long long m, ret = -1;
  while (l <= r) {
    m = (l + r) / 2;
    if (arr[m] == x) {
      ret = m;
      r = m - 1;
    } else if (arr[m] < x) {
      l = m + 1;
    } else {
      r = m - 1;
    }
  }
  return ret;
}

### Prompt

Construct a cpp code solution to the problem outlined:

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;
long long gcd(long long a, long long b);
long long lcm(long long a, long long b);
vector<long long> prime;
bitset<000000 + 1> isPrime;
vector<long long> primeFactor;
vector<long long> uniqueprimeFactor;
vector<long long> divisors[000000 + 1];
vector<long long> divNum;
long long phiValue[000000 + 1];
void seive(long long lim);
void primeFactorial(long long n);
void eulerPhi(long long lim);
void divGenerator(long long n);
void div(long long n);
long long bigMod(long long b, long long p, long long m);
long long nCr(long long n, long long r);
long long string2int(string str);
string int2string(long long num);
long long bs(long long arr[], long long l, long long r, long long x);
long long prevMatch(long long arr[], long long l, long long r, long long x);
long long range(long long arr[], long long l, long long r, long long left,
                long long right);
long long firstMarched(long long arr[], long long l, long long r, long long x);
long long vbs(vector<long long> arr, long long l, long long r, long long x);
long long vprevMatch(vector<long long> arr, long long l, long long r,
                     long long x);
long long vrange(vector<long long> arr, long long l, long long r,
                 long long left, long long right);
long long vfirstMarched(vector<long long> arr, long long l, long long r,
                        long long x);
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string str;
  cin >> str;
  long long k, a[26];
  cin >> k;
  long long mx = -1;
  for (long long i = 0; i < 26; ++i) {
    cin >> a[i];
    mx = max(mx, a[i]);
  }
  long long sum = 0;
  for (long long i = 0; i < (long long)str.size(); ++i) {
    sum = sum + (i + 1) * a[((int)(str[i]) - 97)];
  }
  for (long long i = (long long)str.size() + 1; k > 0; ++i) {
    sum = sum + i * mx;
    k--;
  }
  cout << sum << endl;
  return 0;
}
long long gcd(long long a, long long b) {
  if (a % b == 0) {
    return b;
  }
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
  long long ret = ((a / gcd(a, b)) * b);
  return ret;
}
void seive(long long lim) {
  isPrime.set();
  prime.push_back(2);
  for (long long i = 3; i <= lim; i += 2) {
    if (isPrime[i]) {
      prime.push_back(i);
      for (long long j = i * i; j <= lim; j += (i << 1)) {
        isPrime[j] = 0;
      }
    }
  }
}
void primeFactorial(long long n) {
  for (long long i = 0; prime[i] * prime[i] <= n; i++) {
    long long cnt = 0;
    while (n % prime[i] == 0) {
      n = n / prime[i];
      cnt++;
      primeFactor.push_back(prime[i]);
    }
    if (cnt > 0) {
      uniqueprimeFactor.push_back(prime[i]);
    }
    if (n == 1) {
      break;
    }
  }
  if (n > 1) {
    primeFactor.push_back(n);
    uniqueprimeFactor.push_back(n);
  }
}
void eulerPhi(long long lim) {
  for (long long i = 0; i <= lim; ++i) {
    phiValue[i] = i;
  }
  for (long long i = 2; i <= lim; ++i) {
    if (phiValue[i] == i) {
      for (long long j = i; j <= lim; j += i) {
        phiValue[j] = (phiValue[j] * (i - 1)) / i;
      }
    }
  }
  phiValue[0] = 1;
  phiValue[1] = 1;
}
long long bigMod(long long b, long long p, long long m) {
  long long y;
  if (b == 0) {
    return 0;
  }
  if (p == 0) {
    return 1;
  }
  if (p % 2 == 0) {
    y = bigMod(b, p / 2, m);
    y = (y * y) % m;
  } else {
    y = b % m;
    y = (y * bigMod(b, p - 1, m) % m) % m;
  }
  return (y + m) % m;
}
long long nCr(long long n, long long r) {
  long long p = 1, k = 1;
  if (n - r < r) {
    r = n - r;
  }
  if (r != 0) {
    while (r) {
      p *= n;
      k *= r;
      long long m = gcd(p, k);
      p /= m;
      k /= m;
      n--;
      r--;
    }
  } else {
    p = 1;
  }
  return p;
}
void divGenerator(long long n) {
  for (long long i = 1; i <= n; i++) {
    for (long long j = i; j <= n; j += i) {
      divisors[j].push_back(i);
    }
  }
}
long long string2int(string str) {
  long long cnt = 1, sum = 0;
  for (long long i = str.length() - 1; i >= 0; i--) {
    long long typcast = (int)(str[i]) - 48;
    sum = sum + typcast * cnt;
    cnt = cnt * 10;
  }
  return sum;
}
string int2string(long long num) {
  string str = "";
  while (num > 0) {
    int ch;
    ch = ((num) % 10) + 48;
    str += char(ch);
    num = num / 10;
  }
  reverse(str.begin(), str.end());
  return str;
}
void div(long long n) {
  for (long long i = 1; i * i <= n; ++i) {
    if (n % i == 0) {
      if (i != (n / i)) {
        divNum.push_back(i);
        divNum.push_back(n / i);
      } else {
        divNum.push_back(i);
      }
    }
  }
  sort(divNum.begin(), divNum.end());
}
long long bs(long long arr[], long long l, long long r, long long x) {
  long long m;
  while (l <= r) {
    m = (l + r) / 2;
    if (arr[m] == x) {
      return m;
    } else if (arr[m] < x) {
      l = m + 1;
    } else {
      r = m - 1;
    }
  }
  return -1;
}
long long vbs(vector<long long> arr, long long l, long long r, long long x) {
  long long m;
  while (l <= r) {
    m = (l + r) / 2;
    if (arr[m] == x) {
      return m;
    } else if (arr[m] < x) {
      l = m + 1;
    } else {
      r = m - 1;
    }
  }
  return -1;
}
long long prevMatch(long long arr[], long long l, long long r, long long x) {
  long long m, ret = -1;
  while (l <= r) {
    m = (l + r) / 2;
    if (arr[m] <= x) {
      ret = m;
      l = m + 1;
    } else {
      r = m - 1;
    }
  }
  return ret;
}
long long vprevMatch(vector<long long> arr, long long l, long long r,
                     long long x) {
  long long m, ret = -1;
  while (l <= r) {
    m = (l + r) / 2;
    if (arr[m] <= x) {
      ret = m;
      l = m + 1;
    } else {
      r = m - 1;
    }
  }
  return ret;
}
long long range(long long arr[], long long l, long long r, long long left,
                long long right) {
  long long ret;
  ret = prevMatch(arr, l, r, right) - prevMatch(arr, l, r, left - 1);
  return ret;
}
long long vrange(vector<long long> arr, long long l, long long r,
                 long long left, long long right) {
  long long ret;
  ret = vprevMatch(arr, l, r, right) - vprevMatch(arr, l, r, left - 1);
  return ret;
}
long long firstMarched(long long arr[], long long l, long long r, long long x) {
  long long m, ret = -1;
  while (l <= r) {
    m = (l + r) / 2;
    if (arr[m] == x) {
      ret = m;
      r = m - 1;
    } else if (arr[m] < x) {
      l = m + 1;
    } else {
      r = m - 1;
    }
  }
  return ret;
}
long long vfirstMarched(vector<long long> arr, long long l, long long r,
                        long long x) {
  long long m, ret = -1;
  while (l <= r) {
    m = (l + r) / 2;
    if (arr[m] == x) {
      ret = m;
      r = m - 1;
    } else if (arr[m] < x) {
      l = m + 1;
    } else {
      r = m - 1;
    }
  }
  return ret;
}

```