import re S = input() right = re.compile(r"\*.*\^.*\^") left = re.compile(r"\^.*\^.*\*") rc = 0 lc = 0 for i in range(len(S)): rf = False lf = False for j in range(i + 4, len(S)): if S[i] == '(' and S[j] == ')': if not rf and right.search(S[i + 1:j]): rc += S.count(')', j) rf = True if not lf and left.search(S[i + 1:j]): lc += S.count(')', j) lf = True if rf and lf: break print(lc, rc)