#include <bits/stdc++.h>
using namespace std;
int vocala(char c) {
  if (c == 'a' || c == 'A' || c == 'e' || c == 'E' || c == 'i' || c == 'I' ||
      c == 'o' || c == 'O' || c == 'u' || c == 'U')
    return 1;
  if (c == 'y' || c == 'Y') return 1;
  return 0;
}
int isprime(long long n) {
  if (n <= 1) return 0;
  if (n <= 3) return 1;
  if (n % 2 == 0 || n % 3 == 0) return 0;
  for (int i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return 0;
  return 1;
}
int isfibo(long long n) {
  long long a = 5 * n * n + 4;
  long long b = a - 8;
  if (sqrt(a) == int(sqrt(a)) || sqrt(b) == int(sqrt(b))) return 1;
  return 0;
}
int gcd(long long a, long long b) {
  long long r;
  while (b) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
ifstream in("input.txt");
ofstream out("output.txt");
long long const nrmax = 1e18;
long long v[50];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  long long k;
  cin >> k;
  long long maxi = 0;
  for (int i = 1; i <= 26; ++i) {
    cin >> v[i];
    maxi = max(maxi, v[i]);
  }
  long long u = 0;
  for (int i = 0; i < s.size(); ++i) {
    int x = v[int(s[i] - 'a') + 1];
    u += (i + 1) * x;
  }
  for (int i = s.size() + 1; i <= s.size() + k; ++i) {
    u += i * maxi;
  }
  cout << u << '\n';
  in.close();
  out.close();
  return 0;
}
