#include <bits/stdc++.h>
using namespace std;
int main() {
  int k, max = 0, flag = 1;
  vector<int> val(26);
  long long sum = 0;
  string s;
  cin >> s;
  cin >> k;
  for (int i = 0; i < 26; i++) {
    cin >> val[i];
    if (val[i] > max) max = val[i];
  }
  for (int i = s.size() - 1; i >= 0; i--) {
    int j = ((int)s[i]) - 97;
    if (flag) {
      if (val[j] > max)
        sum = sum + val[j] * (i + k + 1);
      else {
        sum = sum + val[j] * (i + 1) + max * (((2 * (i + 2) + k - 1) * k) / 2);
        flag = 0;
      }
    } else
      sum = sum + (i + 1) * val[j];
  }
  cout << sum;
}
