def nCr(n, r) r = n - r if n - r < r return 1 if r == 0 a = ((n-r+1)..n).inject(&:*) b = (1..r).inject(&:*) return Rational(a, b).to_i end def calc_l(cnt) return 0 if cnt < 3 return (2..(cnt-1)).map{|n| nCr(n, 2) * nCr(cnt - n, 1)}.max end def calc_o(cnt) return 0 if cnt < 2 q = cnt / 2 return q * (cnt - q) end S = "abcdefghijklmnopqrstuvwxyz" CS = Hash[$stdin.read.split.map(&:to_i).map.with_index{|n,i| [S[i], n.to_i]}] h, e, l, o, w, r, d = CS["h"], CS["e"], CS["l"], CS["o"], CS["w"], CS["r"], CS["d"] puts h * e * calc_l(l) * calc_o(o) * w * r * d