#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-10;
const int INF = 1 << 28;
const long long INFL = 1LL << 62;
string res[] = {"NO", "YES"};
int main() {
  string s;
  cin >> s;
  int k, mx = 0;
  cin >> k;
  long ans = 0;
  map<char, int> m;
  for (char c = 'a'; c <= 'z'; ++c) {
    int v;
    cin >> v;
    mx = max(mx, v);
    m[c] = v;
  }
  for (int i = 0; i < (int)(s).size(); ++i) {
    ans += (m[s[i]] * (i + 1));
  }
  int d = (int)(s).size() + 1;
  while (k--) {
    ans += (d * mx);
    d++;
  }
  cout << ans << endl;
}
