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