#include <bits/stdc++.h>
using namespace std;
vector<int> pb;
vector<int> name;
vector<char> life;
vector<int> who;
set<int> kshe;
map<long, int> am;
vector<pair<int, int> > mk;
long long lalaland[100009], lala[100009];
int main() {
  string s;
  cin >> s;
  int n;
  scanf("%d", &n);
  int ss[27];
  for (int i = 0; i < 26; i++) {
    scanf("%d", &ss[i]);
    name.push_back(ss[i]);
  }
  sort(name.begin(), name.end());
  int am = name[name.size() - 1];
  for (char i = 'a'; i <= 'z'; i++) {
    life.push_back(i);
  }
  int k;
  for (int i = 0; i < s.length(); i++) {
    for (int m = 0; m < life.size(); m++) {
      if (s[i] == life[m]) {
        pb.push_back(ss[m]);
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    pb.push_back(am);
  }
  int l = 1;
  long sum = 0;
  for (int i = 0; i < pb.size(); i++) {
    sum += (l * pb[i]);
    l++;
  }
  printf("%ld\n", (sum));
  name.clear();
  pb.clear();
  life.clear();
  return 0;
}
