#include <bits/stdc++.h>
using namespace std;
string str;
int n, m;
int a[100];
int main() {
  cin >> str;
  cin >> n;
  int m = 0;
  for (int i = 0; i < 26; ++i) {
    cin >> a[i];
    m = max(a[i], m);
  }
  int ans = 0;
  for (int i = 0; i < str.length(); ++i) {
    ans += a[str[i] - 'a'] * (i + 1);
  }
  for (int i = str.length() + 1; i <= str.length() + n; ++i) ans += m * i;
  cout << ans << endl;
  return 0;
}
