#include <bits/stdc++.h>
int main() {
  char s[1001];
  int k;
  int f[26];
  int i;
  int max = -1;
  long long sm = 0;
  scanf("%s", s);
  scanf("%d", &k);
  for (i = 0; i < 26; i++) {
    scanf("%d", &f[i]);
    if (f[i] > max) {
      max = f[i];
    }
  }
  for (i = 0; i < strlen(s); i++) {
    sm = sm + ((i + 1) * f[s[i] - 97]);
  }
  int c = 0;
  while (c < k) {
    sm = sm + ((i + 1) * max);
    c++;
    i++;
  }
  printf("%I64d\n", sm);
  return 0;
}
