#include <bits/stdc++.h>
using namespace std;
const int N = 1234, M = 26;
char s[N];
int w[M];
int main() {
  int ans = 0, max_w = 0, k;
  scanf("%s%d", s, &k);
  for (int i = 0; i < M; ++i) scanf("%d", w + i), max_w = max(max_w, w[i]);
  for (int i = 0, n = strlen(s); i < n; ++i) ans += (i + 1) * w[s[i] - 'a'];
  for (int i = 0, n = strlen(s); i < k; ++i) ans += (i + n + 1) * max_w;
  printf("%d\n", ans);
  return 0;
}
