#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>

int main() {
    std::vector<int> h(26);
    for (auto& hi : h) {
        std::cin >> hi;
    }
    std::string s; std::cin >> s;
    int width = 0;
    int height = 0;
    for (char c : s) {
        width += 1;
        height = std::max(height, h[c - 'a']);
    }
    std::cout << (width * height) << std::endl;
    return 0;
}