#include <bits/stdc++.h>
using namespace std;
int w[26], n, k;
string s;
int main() {
  cin >> s >> k;
  memset(w, 0, sizeof(w));
  int res = 0, maxx = 0;
  for (int i = 0; i < 26; i++) cin >> w[i], maxx = max(w[i], maxx);
  for (int i = 0; i < s.length(); i++) res += (i + 1) * w[s[i] - 'a'];
  for (int i = s.length() + 1; i <= s.length() + k; i++) res += i * maxx;
  cout << res << endl;
  return 0;
}
