fn main [ var seq := read_lazy(h[0]); var sum := 0; var do_state := true; while len_greater_than(seq, 0) do [ if list_begins_with(seq, "do()") then [ do_state := true; seq := seq[4 .. ]; continue; ] if list_begins_with(seq, "don't()") then [ do_state := false; seq := seq[7 .. ]; continue; ] if not list_begins_with(seq, "mul(") then [ seq := seq[1 .. ]; continue; ] seq := seq[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]); if do_state then sum += n1 * n2; seq := seq[par + 1 .. ]; ] write(h[1], ntos(sum) + nl); ]