#include using namespace std; typedef long long LL; typedef pair PII; typedef long double LD; typedef vector VI; typedef vector VVI; const int mod = 1000000007; #define all(x) (x).begin(), (x).end() #define bitCount __builtin_popcount const int maxn = 100005; const int inf = 1e8; int main() { VI h(26); for (int i = 0; i < 26; ++i) { scanf("%d", &h[i]); } string s; int m = 0; cin >> s; for (auto c : s) { m = max(m, h[c - 'a']); } cout << m * s.size(); return 0; }