#include <bits/stdc++.h>
using namespace std;
int main() {
  int m = 0, k = 0, p = 0, i = 1;
  string s;
  cin >> s;
  int n, a[27];
  cin >> n;
  for (i = 1; i < 27; i++) cin >> a[i], m = max(m, a[i]);
  for (i = 0; i < s.length(); i++) k += a[s[i] - 96] * (i + 1);
  while (n--) i++, p += i * m;
  cout << k + p;
}
