#include <bits/stdc++.h>
using namespace std;
int value(string s, int a[]) {
  int n = s.size(), res = 0;
  for (int i = 0; i < n; i++) {
    res = res + ((i + 1) * a[(s[i] - 97)]);
  }
  return res;
}
int main() {
  string s;
  int k, a[26];
  cin >> s;
  cin >> k;
  int max = 0, maxchar = 0;
  for (int i = 0; i < 26; i++) {
    cin >> a[i];
    if (a[i] > max) {
      max = a[i];
      maxchar = i;
    }
  }
  char s2 = maxchar + 97;
  s.append(k, s2);
  cout << value(s, a);
}
