fn main [ var seq := read_lazy(h[0]); var sum := 0; while true do [ var pos := list_search_substring(seq, "mul("); if pos = -1 then break; seq := seq[pos + 4 .. ]; var comma := list_search(seq, ','); if comma <= 0 or comma > 3 then continue; var par := list_search(seq, ')'); if par <= comma + 1 or par > comma + 4 then continue; if list_search_fn(seq[ .. comma], lambda (b : byte) [ return b < '0' or b > '9'; ]) >= 0 then continue; if list_search_fn(seq[comma + 1 .. par], lambda (b : byte) [ return b < '0' or b > '9'; ]) >= 0 then continue; var n1 := ston(seq[ .. comma]); var n2 := ston(seq[comma + 1 .. par]); sum += n1 * n2; seq := seq[par + 1 .. ]; ] write(h[1], ntos(sum) + nl); ]