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