import std.algorithm, std.array, std.container, std.range; import std.string, std.conv, std.math, std.random; import std.stdio, std.typecons; void main() { auto ci = iota(26).map!(i => readln.chomp.to!long).array; long r = 1; r *= ci['h' - 'a']; r *= ci['e' - 'a']; r *= ci['w' - 'a']; r *= ci['r' - 'a']; r *= ci['d' - 'a']; r *= calc_o(ci['o' - 'a']); r *= calc_l(ci['l' - 'a']); writeln(r); } long calc_o(long n) { if (n < 2) return 0; else return iota(1, n).map!(x => x * (n - x)).reduce!(max); } long calc_l(long n) { if (n < 3) return 0; else return iota(2, n).map!(x => x * (x - 1) / 2 * (n - x)).reduce!(max); }