#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[26];
  string s;
  int n, m = 0;
  long t = 0;
  cin >> s >> n;
  for (int i = 0; i < 26; i++) {
    cin >> a[i];
    if (a[i] > a[m]) m = i;
  }
  for (int i = 0; i < s.length(); i++) t += (i + 1) * a[s[i] - 'a'];
  for (int i = s.length(); i < s.length() + n; i++) t += (i + 1) * a[m];
  cout << t;
  return 0;
}
