#include <bits/stdc++.h>
using namespace std;
int mx = -1;
char s[1003];
int a[26];
inline int max1(int x, int y) { return (x > y) ? x : y; }
int main() {
  int x, y, k;
  cin >> s >> y;
  for (int i = 0; i < 26; i++) {
    cin >> k;
    mx = max1(k, mx);
    a[i] = k;
  };
  long long ans = 0;
  for (int i = 0; i < strlen(s); i++)
    if (s[i] >= 'a' && s[i] <= 'z') ans += (i + 1) * a[s[i] - 'a'];
  x = strlen(s);
  ans += (((x + y) * (x + y + 1)) / 2 - (x * (x + 1)) / 2) * (mx);
  cout << ans;
  return 0;
}
