#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  int q, n, s = 0, max = 0;
  cin >> n;
  int i, arr[26];
  for (i = 0; i < 26; i++) {
    cin >> arr[i];
    if (max < arr[i]) max = arr[i];
  }
  int k = str.length();
  for (i = 0; i < k; i++) {
    q = str[i] - 96;
    s += (i + 1) * arr[q - 1];
  }
  q = (k + n + 1) * (k + n) / 2 - k * (k + 1) / 2;
  cout << s + q * max;
}
