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