#include <bits/stdc++.h>
using namespace std;
int main() {
  int k;
  string s;
  cin >> s >> k;
  int n = s.size();
  int val[26];
  for (int i = 0; i < 26; i++) cin >> val[i];
  int mx = *max_element(val, val + 26);
  int ans = 0;
  int idx = 1;
  for (char x : s) ans += (val[x - 'a']) * idx, idx++;
  for (int j = n + 1; j <= n + k; j++) ans += mx * j;
  cout << ans;
}
