from bisect import bisect S = input() N = len(S) LB = [] M = [] A = [] ansr = 0 ansl = 0 for i, s in enumerate(S): if s == "(": LB.append(i) if s == "^": M.append(i) if s == "*": A.append(i) if s == ")": if A: x = A[-1] if M: y = bisect(M, x) - 1 if y > 0: y = M[y - 1] if LB: z = bisect(LB, y) #print("L", A[z - 1], y, x) ansl += z if len(M) > 1: x = M[-2] if A: y = bisect(A, x) - 1 if LB and y >= 0: z = bisect(LB, A[y]) #print("R", LB[z - 1], A[y], x) ansr += z print(ansl, ansr)