#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int l = s.length();
  int p = 0;
  int k;
  cin >> k;
  int a[26];
  int maxx = 0;
  for (int i = 0; i < 26; i++) {
    cin >> a[i];
    if (a[i] > maxx) maxx = a[i];
  }
  int value = 0;
  for (int i = 0; i < l; i++) {
    value += (i + 1) * (a[int(s[i] - 'a')]);
  }
  for (int i = 1; i <= k; i++) p = p + i + l;
  value += (p * maxx);
  cout << value << endl;
  return 0;
}
