#include <bits/stdc++.h>
using namespace std;
int ma, k, s, i, a[29], kq;
int main() {
  string s;
  cin >> s;
  cin >> k;
  ma = a[0];
  for (i = 0; i < 26; i++) {
    cin >> a[i];
    if (ma < a[i]) ma = a[i];
  }
  kq = 0;
  for (i = 0; i < s.length(); i++) kq = kq + a[(int)s[i] - 96 - 1] * (i + 1);
  for (i = s.length() + 1; i <= s.length() + k; i++) kq = kq + ma * i;
  cout << kq;
  return 0;
}
