using System.Collections.Generic; using static System.Math; using System; public class Hello { static void Main() { var ap = "abcdefghijklmnopqrstuvwxyz"; var d = new Dictionary(); for (int i = 0; i < 26; i++) d[ap[i]] = int.Parse(Console.ReadLine().Trim()); var hw = "hewrd"; var ans = 1L; foreach (var x in hw) { ans *= d[x]; if (ans == 0) { Console.WriteLine(0); goto exit; } } ans *= getL(d['l']); if (ans == 0) { Console.WriteLine(0); goto exit; } ans *= getO(d['o']); if (ans == 0) { Console.WriteLine(0); goto exit; } Console.WriteLine(ans); exit:; } static int getO (int n) { if (n < 2) return 0; return n / 2 * (n - n / 2); } static int getL (int n) { if (n < 3) return 0; var ans = 0; for (int i = 2; i <= n -1; i++) { var w = (i * (i - 1)) / 2 * (n - i); ans = Max(ans, w); } return ans; } }