l=r=0 gets.scan(?(){ s=$' t=s.dup l += 1 while t.sub!(/(\^.*?\^.*?\*.*?)\)/,'\1') r += 1 while s.sub!(/(\*.*?\^.*?\^.*?)\)/,'\1') } puts"#{l} #{r}"