#include <bits/stdc++.h>
using namespace std;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c* x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug& operator<<(const c&) {
    return *this;
  }
};
int main() {
  map<char, int> m;
  string s;
  cin >> s;
  int k;
  cin >> k;
  int maxi = -1;
  for (int i = 0; i < 26; i++) {
    int x;
    cin >> x;
    m[(char)('a' + i)] = x;
    maxi = max(maxi, x);
  }
  debug() << " ["
          << "m"
             ": "
          << (m) << "] ";
  long long value = 0;
  for (int i = 1; i <= (int)s.size(); i++) {
    value += (m[s[i - 1]] * i);
  }
  debug() << " ["
          << "value"
             ": "
          << (value) << "] ";
  for (int i = (int)s.size() + 1; i <= (int)s.size() + k; i++) {
    value += (maxi * i);
  }
  cout << value << "\n";
}
