#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, x, n, k, m = 0, f = 0, j = 1;
  int a[26];
  string s;
  cin >> s;
  n = s.length();
  cin >> k;
  k = k + n;
  for (i = 0; i < 26; i++) {
    cin >> a[i];
    m = max(m, a[i]);
  }
  for (i = 0; i < n; i++) {
    f = f + a[s[i] - 'a'] * j;
    j++;
  }
  f = f + ((k * (k + 1)) / 2 - (n * (n + 1)) / 2) * m;
  cout << f << endl;
}
