#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int add;
  cin >> add;
  map<char, int> map1;
  int max1 = 0, sum = 0, count = 1;
  for (char a = 'a'; a <= 'z'; a++) {
    cin >> map1[a];
    max1 = max(max1, map1[a]);
  }
  for (int i = 0; i < s.size(); i++) {
    sum += count * map1[s[i]];
    count++;
  }
  for (int i = 0; i < add; i++) {
    sum += count * max1;
    count++;
  }
  cout << sum << endl;
}
