#include using namespace std; long long dpa[10000][5]; long long dpb[10000][5]; int main(){ string s;cin>>s; if(s[0] == '('){ dpa[0][0] = 1; dpb[0][0] = 1; } for(int i = 1; s.size() > i; i++){ if(s[i] == '('){ dpa[i][0] = dpa[i-1][0]+1; dpb[i][0] = dpb[i-1][0]+1; }else if(s[i] == '^'){ dpa[i][1] = dpa[i-1][0]; dpa[i][2] = dpa[i-1][1]; dpb[i][2] = dpb[i-1][1]; dpb[i][3] = dpb[i-1][2]; }else if(s[i] == '*'){ dpa[i][3] = dpa[i-1][2]; dpb[i][1] = dpb[i-1][0]; }else{ dpa[i][4] = dpa[i-1][3]; dpb[i][4] = dpb[i-1][3]; } } cout << dpa[s.size()-1][4] << " " << dpb[s.size()-1][4] << endl; }