#include <bits/stdc++.h>
int main() {
  char str[1005];
  int n, m, i, j;
  int len = 0;
  int str1[27];
  while (scanf("%s", str) != EOF) {
    scanf("%d", &n);
    int max = 0;
    for (i = 0; i < 26; i++) {
      scanf("%d", &str1[i]);
      if (max < str1[i]) {
        max = str1[i];
      }
    }
    int sum = 0;
    for (i = 1; i <= strlen(str); i++) {
      sum += str1[str[i - 1] - 'a'] * i;
    }
    for (j = i; j <= strlen(str) + n; j++) {
      sum += max * j;
    }
    printf("%d\n", sum);
  }
}
