#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int n, max = -1;
  cin >> s;
  cin >> n;
  int a[26];
  for (int i = 0; i < 26; i++) {
    cin >> a[i];
    if (max < a[i]) {
      max = a[i];
    }
  }
  long int sum = 0;
  for (int p = s.length() + 1; p <= (s.length() + n); p++) {
    sum += (p * max);
  }
  for (int j = 0; j < s.length(); j++) {
    for (int z = 0; z < 26; z++) {
      if ((s[j] - 'a') == z) sum += ((j + 1) * a[z]);
    }
  }
  cout << sum;
  return 0;
}
