#include <bits/stdc++.h>
using namespace std;
struct io {
  template <class T>
  static inline T next() {
    T x;
    std::cin >> x;
    return x;
  }
  template <class T, typename Fun>
  static inline T next(Fun f) {
    T x;
    std::cin >> x;
    return f(x);
  }
  static inline void read_file(const char* s) {}
  static inline void write_file(const char* s) { std::freopen(s, "w", stdout); }
  template <class T>
  static inline std::vector<T> next_array(const int n) {
    std::vector<T> row(n);
    for (int i = 0; i < n; ++i) row[i] = io::next<T>();
    return row;
  }
  template <class T, typename Fun>
  static inline std::vector<T> next_array(const int n, Fun f) {
    std::vector<T> row(n);
    for (int i = 0; i < n; ++i) row[i] = io::next<T>(f);
    return row;
  }
  template <class T>
  static inline std::vector<std::vector<T>> next_table(const int n,
                                                       const int m) {
    std::vector<std::vector<T>> table(n);
    for (int i = 0; i < n; ++i) table[i] = next_array<T>(m);
    return table;
  }
  template <class T, typename Fun>
  static inline std::vector<std::vector<T>> next_table(const int n, const int m,
                                                       Fun f) {
    std::vector<std::vector<T>> table(n);
    for (int i = 0; i < n; ++i) table[i] = next_array<T>(m, f);
    return table;
  }
  static inline std::string next_line(const bool ignore = true) {
    if (ignore) std::cin.ignore();
    std::string s;
    std::getline(std::cin, s);
    return s;
  }
  static inline std::vector<std::string> next_lines(const int n) {
    std::vector<std::string> row(n);
    for (int i = 0; i < n; ++i) std::getline(std::cin, row[i]);
    return row;
  }
  static inline std::vector<std::string> next_lines(
      const std::string& delimiter) {
    std::vector<std::string> row;
    for (std::string value; std::getline(std::cin, value) && value != delimiter;
         row.push_back(value))
      ;
    return row;
  }
  template <class T>
  static inline std::vector<T> next_array_delimiter(const T& delimiter) {
    std::vector<T> row;
    for (T value; std::cin >> value && value != delimiter; row.push_back(value))
      ;
    return row;
  }
  template <class T>
  static inline void print_array(T a[], const int size,
                                 const string& delimiter = " ") {
    std::stringstream sin;
    for (int i = 0; i < size; ++i) sin << a[i] << delimiter;
    print_stream(sin, delimiter.size());
  }
  template <class T>
  static void print(const T& t, const string& delimiter = " ") {
    std::stringstream sin;
    for (const auto& x : t) sin << x << delimiter;
    print_stream(sin, delimiter.size());
  }
  template <class T>
  static inline void print_map(const T& m, const string& delimiter = " ") {
    std::stringstream sin;
    for (const auto& p : m)
      sin << "(" << p.first << ", " << p.second << ")" << delimiter;
    print_stream(sin, delimiter.size());
  }

 private:
  static void print_stream(const std::stringstream& sin, const int ignore) {
    const std::string result = sin.str();
    std::cout << result.substr(0, result.size() - ignore) << std::endl;
  }
};
int main(int argc, char** argv) {
  ios_base::sync_with_stdio(false);
  string s = io::next<string>();
  int k = io::next<int>();
  vector<int> costs = io::next_array<int>(26);
  int value = *max_element(costs.begin(), costs.end());
  int result = 0;
  for (int i = 0; i < s.length(); ++i) {
    const int x = costs[s[i] - 'a'];
    result += x * (i + 1);
  }
  for (int i = s.length() + 1; k-- > 0; ++i) {
    result += value * i;
  }
  cout << result << endl;
  return 0;
}

### Prompt

In CPP, your task is to solve the following problem:

DZY loves collecting special strings which only contain lowercase letters. For each lowercase letter c DZY knows its value wc. For each special string s = s1s2... s|s| (|s| is the length of the string) he represents its value with a function f(s), where 

<image>

Now DZY has a string s. He wants to insert k lowercase letters into this string in order to get the largest possible value of the resulting string. Can you help him calculate the largest possible value he could get? 

Input

The first line contains a single string s (1 ≤ |s| ≤ 103).

The second line contains a single integer k (0 ≤ k ≤ 103).

The third line contains twenty-six integers from wa to wz. Each such number is non-negative and doesn't exceed 1000.

Output

Print a single integer — the largest possible value of the resulting string DZY could get.

Examples

Input

abc
3
1 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1


Output

41

Note

In the test sample DZY can obtain "abcbbc", value = 1·1 + 2·2 + 3·2 + 4·2 + 5·2 + 6·2 = 41.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
struct io {
  template <class T>
  static inline T next() {
    T x;
    std::cin >> x;
    return x;
  }
  template <class T, typename Fun>
  static inline T next(Fun f) {
    T x;
    std::cin >> x;
    return f(x);
  }
  static inline void read_file(const char* s) {}
  static inline void write_file(const char* s) { std::freopen(s, "w", stdout); }
  template <class T>
  static inline std::vector<T> next_array(const int n) {
    std::vector<T> row(n);
    for (int i = 0; i < n; ++i) row[i] = io::next<T>();
    return row;
  }
  template <class T, typename Fun>
  static inline std::vector<T> next_array(const int n, Fun f) {
    std::vector<T> row(n);
    for (int i = 0; i < n; ++i) row[i] = io::next<T>(f);
    return row;
  }
  template <class T>
  static inline std::vector<std::vector<T>> next_table(const int n,
                                                       const int m) {
    std::vector<std::vector<T>> table(n);
    for (int i = 0; i < n; ++i) table[i] = next_array<T>(m);
    return table;
  }
  template <class T, typename Fun>
  static inline std::vector<std::vector<T>> next_table(const int n, const int m,
                                                       Fun f) {
    std::vector<std::vector<T>> table(n);
    for (int i = 0; i < n; ++i) table[i] = next_array<T>(m, f);
    return table;
  }
  static inline std::string next_line(const bool ignore = true) {
    if (ignore) std::cin.ignore();
    std::string s;
    std::getline(std::cin, s);
    return s;
  }
  static inline std::vector<std::string> next_lines(const int n) {
    std::vector<std::string> row(n);
    for (int i = 0; i < n; ++i) std::getline(std::cin, row[i]);
    return row;
  }
  static inline std::vector<std::string> next_lines(
      const std::string& delimiter) {
    std::vector<std::string> row;
    for (std::string value; std::getline(std::cin, value) && value != delimiter;
         row.push_back(value))
      ;
    return row;
  }
  template <class T>
  static inline std::vector<T> next_array_delimiter(const T& delimiter) {
    std::vector<T> row;
    for (T value; std::cin >> value && value != delimiter; row.push_back(value))
      ;
    return row;
  }
  template <class T>
  static inline void print_array(T a[], const int size,
                                 const string& delimiter = " ") {
    std::stringstream sin;
    for (int i = 0; i < size; ++i) sin << a[i] << delimiter;
    print_stream(sin, delimiter.size());
  }
  template <class T>
  static void print(const T& t, const string& delimiter = " ") {
    std::stringstream sin;
    for (const auto& x : t) sin << x << delimiter;
    print_stream(sin, delimiter.size());
  }
  template <class T>
  static inline void print_map(const T& m, const string& delimiter = " ") {
    std::stringstream sin;
    for (const auto& p : m)
      sin << "(" << p.first << ", " << p.second << ")" << delimiter;
    print_stream(sin, delimiter.size());
  }

 private:
  static void print_stream(const std::stringstream& sin, const int ignore) {
    const std::string result = sin.str();
    std::cout << result.substr(0, result.size() - ignore) << std::endl;
  }
};
int main(int argc, char** argv) {
  ios_base::sync_with_stdio(false);
  string s = io::next<string>();
  int k = io::next<int>();
  vector<int> costs = io::next_array<int>(26);
  int value = *max_element(costs.begin(), costs.end());
  int result = 0;
  for (int i = 0; i < s.length(); ++i) {
    const int x = costs[s[i] - 'a'];
    result += x * (i + 1);
  }
  for (int i = s.length() + 1; k-- > 0; ++i) {
    result += value * i;
  }
  cout << result << endl;
  return 0;
}

```