n = gets.chomp n << "E" a = [] c ="" ans = 0 n.each_char do |i| if i =~ /\d/ c << i elsif i =~ /[+*]/ a << c.to_i c = "" a << i elsif i == "E" a << c.to_i end end ans = a[0] a = a.drop(1) a.size.times do |i| if a[i] == "*" ans += a[i+1] elsif a[i] == "+" ans *= a[i+1] end end