#include <bits/stdc++.h>
long long exp(long long x, long long y, long long p) {
  long long res = 1;
  while (y) {
    if (y % 2) res = (res * x % p) % p;
    x = (x * x) % p;
    y /= 2;
  }
  return res;
}
long long expo(long long x, long long y) {
  long long res = 1;
  while (y) {
    if (y % 2) res = (res * x % ((long long)1e9 + 7)) % ((long long)1e9 + 7);
    x = (x * x) % ((long long)1e9 + 7);
    y /= 2;
  }
  return res;
}
long long sub(long long a, long long b) {
  return (a % ((long long)1e9 + 7) - b % ((long long)1e9 + 7) +
          ((long long)1e9 + 7)) %
         ((long long)1e9 + 7);
}
long long mul(long long a, long long b) {
  return ((a % ((long long)1e9 + 7)) * (b % ((long long)1e9 + 7)) +
          ((long long)1e9 + 7)) %
         ((long long)1e9 + 7);
}
long long inv(long long x) { return expo(x, ((long long)1e9 + 7) - 2); }
using namespace std;
void solve() {
  string s;
  cin >> s;
  long long k;
  cin >> k;
  long long a[26];
  for (long long i = 0; i < 26; i++) {
    cin >> a[i];
  }
  long long ans = 0;
  long long n = s.length();
  for (long long i = 0; i < s.length(); i++) {
    ans += (a[s[i] - 'a'] * (i + 1));
  }
  long long q = ((n + k) * (n + k + 1)) / 2 - (n * (n + 1)) / 2;
  ans = ans + *max_element(a, a + 26) * q;
  cout << ans << endl;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
  return 0;
}
