#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  int K;
  cin >> K;
  vector<int> v(26);
  int maxval = 0;
  for (int i = 0; i < 26; ++i) {
    cin >> v[i];
    maxval = max(maxval, v[i]);
  }
  unsigned long long answer = 0;
  S = "@" + S;
  for (int i = 1; i < S.size(); ++i) {
    answer += 1LL * i * v[S[i] - 'a'];
  }
  for (int i = 0; i < K; ++i) {
    answer += 1LL * (i + S.size()) * maxval;
  }
  cout << answer << "\n";
  return 0;
}
