#include <bits/stdc++.h>
using namespace std;
string s;
int k;
vector<int> a;
int main() {
  cin >> s;
  cin >> k;
  a = vector<int>(26, 0);
  int mx = -1;
  for (int i = 0; i < 26; i++) {
    cin >> a[i];
    if (a[i] > mx) mx = a[i];
  }
  int sum = 0;
  for (int i = 0; i < s.size(); i++) sum += (a[s[i] - 'a']) * (i + 1);
  int id = s.size();
  for (int i = 0; i < k; i++) {
    id++;
    sum += id * mx;
  }
  cout << sum << endl;
  return 0;
}
