#include <bits/stdc++.h>
using namespace std;
int w[26], n, k, ans;
string s;
void solve() {
  cin >> s >> k;
  n = s.size();
  for (int i = 0; i < 26; ++i) cin >> w[i];
  for (int i = 0; i < n; ++i) ans += (w[(int)(s[i] - 'a')] * (i + 1));
  int help = -10000;
  for (int i = 0; i < 26; ++i) help = max(help, w[i]);
  for (int i = n; i < n + k; ++i) ans += (help * (i + 1));
  cout << ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
