#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  long long int k, len, m, arr[100], max = 0, i, sum = 0, c;
  cin >> s;
  cin >> k;
  len = s.length();
  m = len + k;
  for (i = 0; i < 26; i++) {
    cin >> arr[i];
    if (arr[i] > max) max = arr[i];
  }
  for (i = 0; i < m; i++) {
    if (i >= len)
      sum = sum + (i + 1) * max;
    else {
      c = (int)s[i];
      sum = sum + (i + 1) * arr[c - 97];
    }
  }
  cout << sum << endl;
  return 0;
}
