#include <bits/stdc++.h>
using namespace std;
int main() {
  int k;
  map<char, int> m;
  string s;
  cin >> s;
  cin >> k;
  int val = 0;
  int cm = 0;
  for (char cc = 'a'; cc <= 'z'; cc++) {
    cin >> m[cc];
    cm = max(cm, m[cc]);
  }
  for (int i = 0; i < s.length(); i++) {
    val += (i + 1) * m[s[i]];
  }
  int len = s.length() + 1;
  for (int i = 1; i <= k; i++) {
    val += len * cm;
    len++;
  }
  cout << val << endl;
  return 0;
}
