def out_of_range?(n) !n.between?(-99999999, 99999999) end def do_mental_arithmetic(a,b) if a.to_s =~ /\A(-?[1-9])(0{2,})\z/ h1, t1 = $1, $2 else return nil end if b.to_s =~ /\A(-?[1-9])(0{2,})\z/ h2, t2 = $1, $2 else return nil end return "#{h1.to_i*h2.to_i}#{(t1+t2)[1..-1]}".to_i end a, b = gets.split.map(&:to_i) if r = do_mental_arithmetic(a, b) puts r else r = a * b if out_of_range?(r) puts "E" else puts r end end