#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  long int k, n;
  int sum = 0;
  int w[26];
  cin >> s;
  cin >> k;
  n = s.length();
  for (int i = 0; i < 26; i++) {
    cin >> w[i];
  }
  vector<int> v;
  vector<int> w1;
  for (int i = 0; i < 26; i++) {
    w1.push_back(w[i]);
  }
  for (int i = 0; i < n; i++) {
    if (s[i] == 'a') v.push_back(w[0]);
    if (s[i] == 'b') v.push_back(w[1]);
    if (s[i] == 'c') v.push_back(w[2]);
    if (s[i] == 'd') v.push_back(w[3]);
    if (s[i] == 'e') v.push_back(w[4]);
    if (s[i] == 'f') v.push_back(w[5]);
    if (s[i] == 'g') v.push_back(w[6]);
    if (s[i] == 'h') v.push_back(w[7]);
    if (s[i] == 'i') v.push_back(w[8]);
    if (s[i] == 'j') v.push_back(w[9]);
    if (s[i] == 'k') v.push_back(w[10]);
    if (s[i] == 'l') v.push_back(w[11]);
    if (s[i] == 'm') v.push_back(w[12]);
    if (s[i] == 'n') v.push_back(w[13]);
    if (s[i] == 'o') v.push_back(w[14]);
    if (s[i] == 'p') v.push_back(w[15]);
    if (s[i] == 'q') v.push_back(w[16]);
    if (s[i] == 'r') v.push_back(w[17]);
    if (s[i] == 's') v.push_back(w[18]);
    if (s[i] == 't') v.push_back(w[19]);
    if (s[i] == 'u') v.push_back(w[20]);
    if (s[i] == 'v') v.push_back(w[21]);
    if (s[i] == 'w') v.push_back(w[22]);
    if (s[i] == 'x') v.push_back(w[23]);
    if (s[i] == 'y') v.push_back(w[24]);
    if (s[i] == 'z') v.push_back(w[25]);
  }
  for (int i = 0; i < n; i++) {
    sum += ((i + 1) * v[i]);
  }
  sort(w1.begin(), w1.end());
  reverse(w1.begin(), w1.end());
  for (int i = n; i < n + k; i++) {
    sum += ((i + 1) * w1[0]);
  }
  cout << sum;
}
