#include <bits/stdc++.h> #define ll long long #define fo(i,n) for(i=0;i<n;++i) #define forr(i,n) for(i=n-1;i>=0;--i) using namespace std; ll gcd(ll a,ll b){while(a&&b)a>b?a%=b:b%=a;return a+b;} ll lcm(ll a,ll b){return a*b/gcd(a,b);} int main(){ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); cerr<<"Start"<<endl; int i; int a[26]; fo(i,26) cin>>a[i]; string s; int max = 0; cin>>s; fo(i,s.length()){ a[s[i]-'a']>max?max=a[s[i]-'a']:max=max; } cout<<s.length()*max<<endl; return 0; }