#include <bits/stdc++.h>
int main() {
  char a[1002];
  int i, j, t, b[1002], k, len;
  int w[26], w1[26];
  long long sum = 0, count = 0;
  gets(a);
  len = strlen(a);
  for (i = 0; i < len; i++) b[i] = a[i] - 97;
  scanf("%d", &k);
  for (i = 0; i < 26; i++) {
    scanf("%d", &w[i]);
    w1[i] = w[i];
  }
  for (i = 0; i < 26; i++)
    for (j = i; j < 26; j++) {
      if (w1[i] < w1[j]) {
        t = w1[i];
        w1[i] = w1[j];
        w1[j] = t;
      }
    }
  for (i = 0; i < len; i++) {
    b[i] = w[b[i]];
    sum += (i + 1) * b[i];
  }
  for (i = 1; i <= len; i++) {
    if (b[len - i] == w1[0]) break;
    count += b[len - i];
  }
  if (count + w1[0] * (len - i + 2) > w1[0] * (len + 1))
    sum += k * count + k * w1[0] * (len - i + 1) + k * w1[0] * (k + 1) / 2;
  else
    sum += k * w1[0] * len + k * w1[0] * (k + 1) / 2;
  printf("%ld\n", sum);
  return 0;
}
