#include <bits/stdc++.h>
using namespace std;
int w[26];
int main() {
  string s;
  cin >> s;
  int k;
  cin >> k;
  int mc = 0;
  for (int i = 0; i < 26; ++i) {
    cin >> w[i];
    mc = max(mc, w[i]);
  }
  int ans = 0;
  for (int i = 0; i < s.size(); ++i) {
    ans += (i + 1) * w[s[i] - 'a'];
  }
  for (int i = 1; i <= k; ++i) ans += (i + s.size()) * mc;
  cout << ans << "\n";
  return 0;
}
