#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int a[123], k, m = 0, sum = 0;
  cin >> s >> k;
  for (int i = 'a'; i <= 'z'; i++) {
    cin >> a[i];
    m = max(m, a[i]);
  }
  for (int i = 0; i < s.size(); i++) sum += (i + 1) * a[s[i]];
  for (int i = s.size() + 1; i <= s.size() + k; i++) sum += i * m;
  cout << sum << endl;
}
