#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string str = "";
  cin >> str;
  int k, arr[27];
  cin >> k;
  long long int max = -1;
  for (long long int i = 0; i < 26; i++) {
    cin >> arr[i];
    if (arr[i] > max) max = arr[i];
  }
  long long int val = 0;
  int n = str.size();
  int i;
  for (i = 1; i <= n; i++) {
    int join = arr[str[i - 1] - 'a'];
    val += join * i;
  }
  int j = n + 1;
  while (k--) {
    val += max * j;
    j++;
  }
  cout << val << endl;
  return 0;
}
