#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int k;
  cin >> k;
  int n = 26;
  int w[n + 1];
  for (int i = 1; i <= n; i++) {
    cin >> w[i];
  }
  int max = *max_element(w + 1, w + n + 1);
  int l = s.length();
  map<char, int> mp;
  map<char, int>::iterator it;
  for (int i = 0; i < 26; i++) {
    mp[char(i + 'a')] = w[i + 1];
  }
  int score = 0;
  for (int i = 0; i < l; i++) {
    for (auto j : mp) {
      if (s[i] == j.first) {
        score = score + (i + 1) * j.second;
      }
    }
  }
  for (int o = l + 1; o <= l + k; o++) {
    score = score + o * max;
  }
  cout << score;
  return 0;
}
