import java.io.IOException; import java.util.Scanner; public class Yukicoder73 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[] alpha = new int[26]; for (int i = 0; i < 26; i++) { alpha[i] = sc.nextInt(); } long maxH = -1, maxO = -1; for (int i = 2; i < alpha['l' - 'a']; i++) { maxH = Math.max(cmb(i, 2) * (alpha['l' - 'a'] - i), maxH); } for (int i = 1; i < alpha['o' - 'a']; i++) { maxO = Math.max(i * (alpha['o' - 'a'] - i), maxO); } System.out.println(maxH * maxO * alpha['h' - 'a'] * alpha['e' - 'a'] * alpha['w' - 'a'] * alpha['r' - 'a'] * alpha['d' - 'a']); } static long cmb(int n, int m) { long c = 1; m = (n - m < m ? n - m : m); for (int ns = n - m + 1, ms = 1; ms <= m; ns++, ms++) { c *= ns; c /= ms; } return c; } }