#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int n, arr[27], sum = 0, sum2 = 0, m, mx, l;
  cin >> s;
  cin >> n;
  m = s.size() + n;
  l = s.size();
  for (int i = 0; i < 26; i++) {
    cin >> arr[i];
  }
  mx = *max_element(arr, arr + 26);
  for (int i = 0; i < s.size(); i++) {
    sum += ((arr[(s[i] - 'a')]) * (i + 1));
  }
  sum2 = ((m * (m + 1) / 2) - (l * (l + 1) / 2)) * mx;
  cout << sum + sum2 << endl;
  return 0;
}
