#include <bits/stdc++.h>
using namespace std;
int pa[100005];
int pb[100005];
bool prime[1000005];
map<string, string> mt;
int main() {
  long long n;
  string s;
  cin >> s;
  long long k;
  cin >> k;
  n = s.length();
  long long max = 0;
  long long sum = 0;
  for (int i = 1; i <= 26; i++) {
    cin >> pa[i];
    if (max < pa[i]) max = pa[i];
  }
  for (int i = 1; i <= k + n; i++) {
    if (i <= n) {
      sum = sum + i * (int)pa[(s[i - 1] - 'a') + 1];
    } else if (i > n) {
      sum = sum + max * i;
    }
  }
  cout << sum;
}
