#include <bits/stdc++.h>
using namespace std;
int slove() {
  string a;
  int n, am = -1, sum = 0;
  cin >> a;
  cin >> n;
  char c = 'a';
  map<char, int> v;
  for (c; c <= 'z'; c++) {
    int k;
    cin >> k;
    v[c] = k;
    if (k > am) am = k;
  }
  int j = a.length();
  for (int i = 0; i < j; i++) {
    sum += (i + 1) * v[a[i]];
  }
  for (int i = 0; i < n; i++) {
    sum += (i + j + 1) * am;
  }
  cout << sum;
  return 0;
}
int main() {
  int t = 1;
  while (t) {
    slove();
    t--;
  }
}
