#include <bits/stdc++.h>
struct debugger {
  template <typename T>
  debugger operator,(const T& v) {
    std::cout << v << " ";
    return (*this);
  }
} dbg;
using namespace std;
int main() {
  std::ios_base::sync_with_stdio(false);
  string s;
  long long wt[26];
  int k;
  cin >> s >> k;
  long long mx = -1;
  for (int i = (0); i <= (25); ++i) {
    long long t;
    cin >> t;
    mx = max(mx, t);
    wt[i] = t;
  }
  long long ans = 0;
  long long ti = 1;
  for (int i = (0); i < (((int)((s).size()))); ++i) {
    ans += wt[s[i] - 'a'] * (ti);
    ti++;
  }
  long long l = ((int)((s).size())) + 1;
  for (int i = (1); i <= (k); ++i) {
    ans += l * mx;
    l++;
  }
  cout << ans << endl;
}
