s = input() left_pos = [i for i, k in enumerate(s) if k == '('] def left_solve(): res = 0 is_first = None tmp_stock = None for i in left_pos: tmp = s[i+1:] if is_first is not None and i < is_first: if tmp_stock is not None: res += tmp_stock continue is_first = None count = 0 for j, elm in enumerate(tmp): if count < 2: if elm == '^': if is_first is None: is_first = j + i count += 1 else: if elm == '*': ttmp = tmp[j+1:] tmp_stock = ttmp.count(')') res += tmp_stock break return res def right_solve(): res = 0 is_first = None tmp_stock = None for i in left_pos: tmp = s[i+1:] if is_first is not None and i < is_first: if tmp_stock is not None: res += tmp_stock continue is_first = None count = 0 for j, elm in enumerate(tmp): if count < 1: if elm == '*': count += 1 if is_first is None: is_first = j + i elif count < 2: if elm == '^': count += 1 else: if elm == '^': ttmp = tmp[j+1:] tmp_stock = ttmp.count(')') res += tmp_stock break return res print(left_solve(), right_solve())