#include <bits/stdc++.h>
using namespace std;
int a[200];
int main() {
  int k, mx = 0, mxin, sum = 0, j;
  char str[1000];
  gets(str);
  cin >> k;
  for (int i = 97; i < 97 + 26; i++) {
    cin >> a[i];
    if (a[i] > mx) mx = a[i];
  }
  for (j = 0; str[j]; j++) {
    sum = sum + (j + 1) * a[str[j]];
  }
  for (int m = j + 1; m <= k + j; m++) {
    sum = sum + m * mx;
  }
  cout << sum << endl;
  return 0;
}
