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