#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int k;
  scanf("%d", &k);
  int a[26], max = -1;
  for (int i = 0; i < 26; i++) {
    scanf("%d", &a[i]);
    if (a[i] > max) max = a[i];
  }
  long long int f = 0;
  for (int i = 0; i < s.size(); i++) {
    f += (i + 1) * a[s[i] - 'a'];
  }
  for (int i = s.size(); i < s.size() + k; i++) f += (i + 1) * max;
  cout << f << endl;
}
