#include <bits/stdc++.h>
using namespace std;
long long MOD = 1e9 + 7;
int main() {
  string s;
  cin >> s;
  int k;
  cin >> k;
  int arr[30];
  arr[0] = -1;
  for (int i = 1; i < 27; i++) cin >> arr[i];
  int sum = 0;
  for (long long i = 0; i < s.length(); i++) {
    int x = s[i] - 'a' + 1;
    sum += (i + 1) * arr[x];
  }
  int ma = *max_element(arr + 1, arr + 27);
  int i = s.length() + 1;
  while (k--) {
    sum += i * ma;
    i++;
  }
  cout << sum;
  return 0;
}
