#include <bits/stdc++.h>
using namespace std;
int MIN(int a, int b) {
  int x = (b > a) ? a : b;
  return x;
}
int MAX(int a, int b) {
  int x = (b < a) ? a : b;
  return x;
}
const int size = 1000007;
const long long modulo = 1000000007;
const long long inf = 1e18;
const double eps = 1e-6;
long long n, m, a[4000], b[4000], k, n25, n50, n100;
int main() {
  char ar[100][100];
  string str;
  while (cin >> str) {
    cin >> k;
    for (int i = 0; i < 26; i++) cin >> a[i];
    long long sum = 0;
    for (int i = 0; i < str.size(); i++) {
      sum += a[str[i] - 97] * (i + 1);
    }
    sort(a, a + 26);
    for (int i = 0; i < k; i++) {
      sum += (a[25] * (str.size() + (i + 1)));
    }
    cout << sum << endl;
  }
  return 0;
}
