S = list(input()) kl = 0 sumL = 0 sumR = 0 si = 0 while si < len(S): s = S[si] if s == "(": flagl = 0 flagr = 0 flagk = 0 kr = 0 countstar = 0 countyama = 0 countstya = 0 Lface = 0 Rface = 0 for ti,t in enumerate(S[si + 1:]): if ti == 0 + flagk and t == "(": flagk = flagk + 1 elif t == "*": countstar = countstar + 1 if countyama >= 2 and flagl == 0: Lface = (flagk + 1) * (S[ti + si + 1:].count(")")) sumL = sumL + Lface flagl = 1 elif t == "^": countyama = countyama + 1 if countstya == 1 and flagr == 0: Rface = (flagk + 1) * (S[ti + si + 1:].count(")")) sumR = sumR + Rface flagr = 1 elif countstar >= 1: countstya = 1 if (flagr == 1 and flagl == 1) or ti == len(S[si + 1:]) -1: if si > 0 and flagk > 0: S = S[:si] + S[si + flagk:] elif flagk > 0: S = [S[0]] + S[si + flagk + 1:] break si = si + 1 print(sumL,sumR)