#include <bits/stdc++.h>
using namespace std;
map<char, int> m;
int main() {
  string s;
  cin >> s;
  int n, x = 0;
  cin >> n;
  char b;
  for (char c = 'a'; c <= 'z'; c++) {
    int d;
    cin >> d;
    m[c] = d;
    if (x < d) {
      x = d;
      b = c;
    }
  }
  int se = s.size();
  long long ans = 0;
  for (int i = 1, j = 0; i <= se; i++, j++) ans += (i * m[s[j]]);
  for (int i = se + 1, j = 0; j < n; i++, j++) ans += (i * m[b]);
  cout << ans << endl;
  return 0;
}
