#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int m = -99, x = 0, l, n;
  cin >> n;
  vector<int> v;
  for (int i = 0; i < 26; i++) {
    int a;
    cin >> a;
    v.push_back(a);
  }
  for (int i = 0; i < s.length(); i++) {
    int p = s[i] - 'a';
    x += (i + 1) * v[p];
  }
  sort(v.begin(), v.end());
  for (int i = s.length() + 1; i <= s.length() + n; i++) {
    x += (i)*v[25];
  }
  cout << x;
}
