#include "bits/stdc++.h" using namespace std; #define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i)) #define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i)) #define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i)) static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL; typedef vector vi; typedef pair pii; typedef vector > vpii; typedef long long ll; template static void amin(T &x, U y) { if(y < x) x = y; } template static void amax(T &x, U y) { if(x < y) x = y; } int main() { char S[10001]; while(~scanf("%s", S)) { int n = (int)strlen(S); int ans[2] = {}; rep(k, 2) { vector nextHat(n + 2, n), nextStar(n + 1, n); vector countRight(n + 1, 0); for(int i = n - 1; i >= 0; -- i) { nextHat[i] = S[i] == '^' ? i : nextHat[i + 1]; nextStar[i] = S[i] == '*' ? i : nextStar[i + 1]; countRight[i] = countRight[i + 1] + (S[i] == ')'); } rep(i, n) if(S[i] == '(') ans[k] += countRight[nextStar[nextHat[nextHat[i] + 1]]]; reverse(S, S + n); rep(i, n) S[i] = S[i] == '(' ? ')' : S[i] == ')' ? '(' : S[i]; } printf("%d %d\n", ans[0], ans[1]); } return 0; }