from bisect import bisect_right S = input().strip() N = len(S) S = "0"+S A = [] B = [] L = [0]*(N+1) R = [0]*(N+1) for i in range(1,N+1): if S[i]=="^": A.append(i) L[i] = L[i-1] R[i] = R[i-1] elif S[i]=="*": B.append(i) L[i] = L[i-1] R[i] = R[i-1] elif S[i]=="(": L[i] = L[i-1]+1 R[i] = R[i-1] elif S[i]==")": L[i] = L[i-1] R[i] = R[i-1]+1 ans1 = 0 pre1 = 0 cur1 = 0 ans2 = 0 pre2 = 0 cur2 = 0 for i in range(2,N-3+1): if S[i]=="^": cur1 = i ind = bisect_right(A,i) if ind==len(A): continue i1 = A[ind] ind1 = bisect_right(B,i1) if ind1==len(B): continue j = B[ind1] ans1 += (L[cur1]-L[pre1])*(R[N]-R[j]) pre1 = cur1 elif S[i]=="*": cur2 = i ind = bisect_right(A,i) if ind==len(A): continue j1 = A[ind] ind1 = bisect_right(A,j1) if ind1==len(A): continue j2 = A[ind1] ans2 += (L[cur2]-L[pre2])*(R[N]-R[j2]) pre2 = cur2 print(ans1,ans2)