#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;


int main() {
    vector<int> hs('z' - 'a' + 1, 0);
    for(auto & h : hs)
    {
        cin >> h;
    }
    
    string s;
    cin >> s;
    
    auto const W = s.size();
    
    auto H = 0;
    
    for(auto const & c : s)
    {
        H = max(H, hs[c - 'a']);
    }
    
    cout << W * H << endl;
    
    return 0;
}