#include <bits/stdc++.h>
using namespace std;
int main() {
  long long s = 0, n, i, alp[26], ma = 0, p;
  string str;
  cin >> str >> n;
  n += str.length();
  vector<int> vec;
  for (i = 0; i < 26; i++) {
    cin >> alp[i];
    ma = max(ma, alp[i]);
  }
  for (i = 0; i < str.length(); i++) s += (alp[str[i] - 'a'] * (i + 1));
  s += (ma * (((n * (n + 1)) - (str.length() * (str.length() + 1))) / 2));
  cout << s;
}
