#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int k;
  cin >> k;
  int sum = 0;
  vector<int> vec;
  map<char, int> mapp;
  for (int i = 97; i < (97 + 26); i++) {
    int ele;
    cin >> ele;
    mapp[char(i)] = ele;
    vec.push_back(ele);
  }
  for (int i = 1; i <= s.size(); i++) {
    sum = sum + (i * mapp[s[i - 1]]);
  }
  int sumi = 0;
  int max = *max_element(vec.begin(), vec.end());
  for (int i = (s.size() + 1); i <= s.size() + k; i++) {
    sum = sum + (i * max);
  }
  cout << sum;
  return 0;
}
