#include <bits/stdc++.h>
using namespace std;
int main() {
  int arr[26];
  string str;
  cin >> str;
  int k, l;
  cin >> k;
  l = str.length();
  int maxi = 0;
  for (int i = 0; i < 26; i++) cin >> arr[i], maxi = max(maxi, arr[i]);
  int sum = 0;
  for (int i = 0; i < l; i++) {
    sum = sum + (i + 1) * arr[str[i] - 'a'];
  }
  for (int i = 0, j = l + 1; i < k; j++, i++) {
    sum = sum + j * maxi;
  }
  cout << sum << endl;
  return 0;
}
