#include #include #include #include #include int main() { std::vector 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; }