#include <bits/stdc++.h>
using namespace std;
const unsigned long long M = 1000000007;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t = 1;
  while (t--) {
    string s;
    cin >> s;
    int k, sum = 0;
    cin >> k;
    int a[26];
    vector<int> b;
    for (int i = 0; i < 26; i++) {
      cin >> a[i];
      b.push_back(a[i]);
    }
    sort(b.rbegin(), b.rend());
    for (int i = 0; i < s.length(); i++) {
      int j = (s[i] - 'a');
      sum += a[j] * (i + 1);
    }
    int c = s.length() + 1;
    while (k--) {
      sum += (b[0] * c);
      c++;
    }
    cout << sum << endl;
  }
  return 0;
}
