#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, x = 0, k = 0, i, j, y = 0, c, max = -1;
  string s;
  cin >> s;
  int l = s.length();
  cin >> n;
  int a[29];
  for (i = 0; i < 26; i++) {
    cin >> a[i];
    if (max < a[i]) max = a[i];
  }
  for (i = 0; i < l; i++) {
    c = (int)s[i];
    j = a[c - 97];
    k += ((i + 1) * j);
  }
  i = l + 1;
  while (n--) {
    x += (i);
    i++;
  }
  y = (x * max) + k;
  cout << y << endl;
  return 0;
}
