#include <bits/stdc++.h>
using namespace std;
string str;
int a[27];
int main() {
  cin >> str;
  int b;
  cin >> b;
  int max = -1;
  for (int j = 0; j < 26; j++) {
    cin >> a[j];
    if (max < a[j]) max = a[j];
  }
  int result = 0;
  for (int i = 0; i < str.size(); i++) {
    result = result + (i + 1) * a[(int)str[i] - 97];
  }
  for (int j = 1; j <= b; j++) {
    result = result + (str.size() + j) * max;
  }
  cout << result;
  return 0;
}
