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