s = gets.strip #puts s re_l = /\^.*\^.*\*/ # ^^* re_r = /\*.*\^.*\^/ # *^^ #p re_l.match(s) #p re_r.match(s) count_l = 0 count_r = 0 (0...s.length - 1).each do |i| flag_l = false flag_r = false if s[i] == '(' (i+4...s.length).each do |j| if s[j] == ')' #puts s[i..j] if !flag_l if re_l.match(s[i..j]) count_l += 1 flag_l = true end else count_l += 1 end if !flag_r if re_r.match(s[i..j]) count_r += 1 flag_r = true end else count_r += 1 end end end end end print "#{count_l} #{count_r}\n"