#!/bin/ruby heights = gets.strip.split.map(&:to_i) word = gets.strip.chars.map {|x| heights[x.ord - 'a'.ord]} puts word.max * word.length