#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int n;
  int arr[26];
  int arr2[26];
  cin >> s;
  int value;
  int sum = 0;
  int add;
  int length = s.size();
  cin >> n;
  for (int i = 0; i < 26; i++) {
    cin >> arr[i];
    arr2[i] = arr[i];
  }
  sort(arr2, arr2 + 26);
  int largest = arr2[25];
  for (int i = 0; i < length; i++) {
    value = s[i];
    int x = abs(97 - value);
    sum = sum + ((i + 1) * arr[x]);
  }
  int last = length + n;
  int sum1 = 0;
  for (int i = length + 1; i <= last; i++) {
    sum1 = sum1 + (i * largest);
  }
  cout << sum1 + sum;
}
