#include <bits/stdc++.h>
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
using namespace std;
using ll = long long;
using ld = long double;
const ll MOD = 1e+9 + 7;
const ll INF = LLONG_MAX;
const int N = (int)2e+5 + 8;
template <typename T>
string itos(T i) {
  stringstream second;
  second << i;
  return second.str();
}
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second < b.second);
}
int main() {
  ios_base ::sync_with_stdio(false);
  cout.tie(NULL);
  cin.tie(NULL);
  string second;
  cin >> second;
  int n;
  cin >> n;
  vector<pair<int, char>> vec;
  int arr[123] = {0};
  for (char i = 'a'; i <= 'z'; i++) {
    int a;
    cin >> a;
    vec.push_back({a, i});
    arr[i] = a;
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  int temp = vec[0].first;
  int index = 1;
  ll res = 0;
  for (int i = 0; i < second.length(); i++) {
    res += index * arr[second[i]];
    index++;
  }
  for (; index <= second.length() + n; index++) {
    res += index * temp;
  }
  cout << res;
}
