#include <bits/stdc++.h>
using namespace std;


int main() {
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */   
  vector<int> hei(26);
  for(int& h:hei)
    cin >> h;
  string str;
  cin>>str;
  int res=0;
  for(char c:str)
    res=max(res,hei[c-'a']);
   res*=str.size();
  cout<<res<<endl;
  return 0;
}