#include <bits/stdc++.h>
using namespace std;
const int inf = numeric_limits<int>::max();
const long long linf = numeric_limits<long long>::max();
const double EPS = 1e-7;
int main() {
  string a;
  cin >> a;
  int k;
  scanf("%d", &k);
  int w[26], top = -1;
  long long points = 0;
  for (int i = 0; i < (26); ++i) {
    scanf("%d", &w[i]);
    if (w[i] >= top) top = w[i];
  }
  int len = a.length();
  for (int i = 0; i < (len); ++i) points += (i + 1) * w[a[i] - 'a'];
  for (int i = 0; i < (k); ++i) points += (i + len + 1) * top;
  cout << points;
  return 0;
}
