#include <bits/stdc++.h>
using namespace std;
int main() {
  string x;
  int k, ma = -1;
  cin >> x >> k;
  vector<int> lc;
  for (int i = 0; i < 26; i++) {
    int a;
    cin >> a;
    ma = max(a, ma);
    lc.push_back(a);
  }
  int s = 0, c = 1;
  for (int i = 0; i < x.size(); i++) {
    int a = x[i];
    s += (c * lc[(a - 97)]);
    c++;
  }
  for (int i = 0; i < k; i++) {
    s += (c * ma);
    c++;
  }
  cout << s << endl;
}
