#include <bits/stdc++.h>
using namespace std;
void alpha() {
  string str;
  cin >> str;
  string str1 = "mmzhr";
  long long int str_size = str.size();
  long long int k;
  cin >> k;
  map<char, int> mp;
  long long int val = 0, max_val = -1;
  for (long long int i = 0; i < 26; i++) {
    cin >> val;
    mp['a' + i] = val;
    if (val > max_val) max_val = val;
  }
  long long int ans = 0;
  for (long long int i = 1; i < str_size + k + 1; i++) {
    if (i <= str_size) {
      ans += i * mp[str[i - 1]];
    } else {
      ans += max_val * i;
    }
  }
  cout << ans << '\n';
  return;
}
int main() {
  alpha();
  return 0;
}
