#include <bits/stdc++.h>
using namespace std;
int main() {
  string second;
  int k;
  getline(cin, second);
  int answer = 0;
  cin >> k;
  vector<int> A(26);
  int maxi = -1;
  char go = ' ';
  for (int i = 0; i < 26; i++) {
    cin >> A[i];
    if (A[i] > maxi) {
      maxi = A[i];
      go = 'a' + i;
    }
  }
  for (int i = 0; i < k; i++) {
    second += go;
  }
  for (int i = 0; i < second.size(); i++) {
    answer += A[second[i] - 'a'] * (i + 1);
  }
  cout << answer << endl;
  return 0;
}
