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