#include <bits/stdc++.h>
using namespace std;
vector<long long> parent, siz;
long long par(long long x) {
  if (parent[x] == x) return x;
  return parent[x] = par(parent[x]);
}
void unionxy(long long x, long long y) {
  long long px = par(x), py = par(y);
  if (px == py) return;
  if (siz[px] > siz[py]) swap(px, py);
  parent[px] = py;
  siz[py] += siz[px];
}
void abcd() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long k;
  string s;
  cin >> s >> k;
  long long n = s.length();
  long long ans = 0;
  vector<long long> arr(26);
  long long lar = INT_MIN;
  long long i;
  for (i = 0; i < 26; i++) {
    cin >> arr[i];
    lar = max(lar, arr[i]);
  }
  for (long long i = 0; i < n + k; i++) {
    if (i < n) {
      ans += (i + 1) * arr[s[i] - 97];
    } else
      ans += (i + 1) * lar;
  }
  cout << ans;
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  abcd();
  cout << endl;
}
