#include <bits/stdc++.h>
using namespace std;
long long int nChoosek(long long int n, long long int k) {
  if (k > n) return 0;
  if (k * 2 > n) k = n - k;
  if (k == 0) return 1;
  int result = n;
  for (int i = 2; i <= k; ++i) {
    result *= (n - i + 1);
    result /= i;
  }
  return result;
}
long long int lcm(long long int a, long long int b) {
  long long int m, n;
  m = a;
  n = b;
  while (m != n) {
    if (m < n) {
      m = m + a;
    } else {
      n = n + b;
    }
  }
  return m;
}
long long int gcd(long long int a, long long int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
vector<int> initializeDiffArray(vector<int>& A) {
  int n = A.size();
  vector<int> D(n + 1);
  D[0] = A[0], D[n] = 0;
  for (int i = 1; i < n; i++) D[i] = A[i] - A[i - 1];
  return D;
}
void update(vector<int>& D, int l, int r, int x) {
  D[l] += x;
  D[r + 1] -= x;
}
int printArray(vector<int>& A, vector<int>& D) {
  for (int i = 0; i < A.size(); i++) {
    if (i == 0)
      A[i] = D[i];
    else
      A[i] = D[i] + A[i - 1];
    cout << A[i] << " ";
  }
  cout << endl;
  return 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin >> s;
  long long int k;
  cin >> k;
  vector<long long int> v;
  for (long long int i = 0; i < 26; i++) {
    long long int x;
    cin >> x;
    v.push_back(x);
  }
  long long int mx = *max_element(v.begin(), v.end());
  long long int sum = 0;
  for (long long int i = 0; i < s.length(); i++) {
    sum += (v[s[i] - 'a']) * (i + 1);
  }
  long long int ln = s.length();
  for (long long int i = 0; i < k; i++) {
    sum += mx * (ln + 1);
    ln++;
  }
  cout << sum << '\n';
  return 0;
}
