#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int n;
  cin >> n;
  map<char, int> m;
  char c = 'a';
  int maxx = -1;
  for (int i = int(1) - (1 > 27); i != (27) - (1 > 27); i += 1 - 2 * (1 > 27)) {
    int x;
    cin >> x;
    m[c++] = x;
    maxx = max(maxx, x);
  }
  int I = 1;
  int ans = 0;
  for (int i = int(0) - (0 > s.length()); i != (s.length()) - (0 > s.length());
       i += 1 - 2 * (0 > s.length())) {
    ans += (I * m[s[i]]);
    I++;
  }
  int keep = s.length() + n;
  keep = (keep * (keep + 1) / 2) - (s.length() * (s.length() + 1) / 2);
  ans += maxx * keep;
  cout << ans << endl;
  return 0;
}
