#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  long long int n, m = 0;
  cin >> n;
  vector<int> A;
  int o = 26;
  while (o--) {
    long long int x;
    cin >> x;
    A.push_back(x);
    if (x > m) m = x;
  }
  long long int l = S.size();
  long long int s = 0;
  for (int i = 0; i < l; i++) {
    s = s + A[int(S[i]) - 97] * (i + 1);
  }
  s = s + (l + n) * (l + n + 1) * m / 2 - l * (l + 1) * m / 2;
  cout << s;
}
