#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int k;
  cin >> s >> k;
  int w[27];
  int t = 0, sum = 0;
  for (int i = 1; i <= 26; i++) {
    cin >> w[i];
    t = max(t, w[i]);
  }
  for (int i = 1; i <= s.length(); i++) {
    sum += w[s[i - 1] - 'a' + 1] * i;
  }
  sum += t * k * (k + 1) / 2 + t * k * s.length();
  cout << sum << endl;
}
