#include <bits/stdc++.h>
using namespace std;
int main() {
  string second;
  int k;
  vector<pair<int, char> > v;
  v.push_back(make_pair(1, 'a'));
  v.push_back(make_pair(2, 'b'));
  v.push_back(make_pair(3, 'c'));
  v.push_back(make_pair(4, 'd'));
  v.push_back(make_pair(5, 'e'));
  v.push_back(make_pair(6, 'f'));
  v.push_back(make_pair(7, 'g'));
  v.push_back(make_pair(8, 'h'));
  v.push_back(make_pair(9, 'i'));
  v.push_back(make_pair(10, 'j'));
  v.push_back(make_pair(11, 'k'));
  v.push_back(make_pair(12, 'l'));
  v.push_back(make_pair(13, 'm'));
  v.push_back(make_pair(14, 'n'));
  v.push_back(make_pair(15, 'o'));
  v.push_back(make_pair(16, 'p'));
  v.push_back(make_pair(17, 'q'));
  v.push_back(make_pair(18, 'r'));
  v.push_back(make_pair(19, 's'));
  v.push_back(make_pair(20, 't'));
  v.push_back(make_pair(21, 'u'));
  v.push_back(make_pair(22, 'v'));
  v.push_back(make_pair(23, 'w'));
  v.push_back(make_pair(24, 'x'));
  v.push_back(make_pair(25, 'y'));
  v.push_back(make_pair(26, 'z'));
  cin >> second >> k;
  int a[26];
  long long ans = 0;
  int mx = 0;
  for (int i = 0; i < 26; i++) {
    cin >> a[i];
    mx = max(mx, a[i]);
  }
  for (int i = 0; i < second.size(); i++) {
    for (int j = 0; j < 26; j++) {
      if (second[i] == v[j].second) {
        ans = ans + a[v[j].first - 1] * (i + 1);
        break;
      }
    }
  }
  int l = second.size();
  for (int i = 0; i < k; i++) {
    l++;
    ans = ans + mx * l;
  }
  cout << ans;
}
