#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int k;
  cin >> k;
  int a[26];
  int maxi = 0;
  for (int i = 0; i < 26; ++i) {
    cin >> a[i];
    maxi = max(maxi, a[i]);
  }
  int val = 0;
  for (int i = 0; i < s.size(); ++i) {
    val += a[s[i] - 97] * (i + 1);
  }
  for (int i = 0; i < k; ++i) {
    val += maxi * (s.size() + i + 1);
  }
  cout << val;
}
