#include <bits/stdc++.h>
using namespace std;
long long int SN(long long int n) { return ((n * (n + 1)) / 2); }
bool isPrime(long long int n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (int i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
int32_t main() {
  long long int count = 0, i, k, n;
  string sr;
  cin >> sr;
  cin >> k;
  char e = 'a';
  unordered_map<char, long long int> umap;
  vector<long long int> arr(26);
  for (i = 0; i <= 25; i++) {
    cin >> arr[i];
    umap[e] = arr[i];
    e++;
  }
  vector<long long int> srr;
  sort(arr.begin(), arr.end());
  for (i = 0; i <= sr.size() - 1; i++) {
    count = count + (i + 1) * (umap[sr[i]]);
  }
  long long int k1;
  for (k1 = i; k--; k1++) {
    count = count + (k1 + 1) * (arr[arr.size() - 1]);
  }
  cout << count << "\n";
}
