#include #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); string s; cin >> s; auto calc = [s](string t) { int ans = 0; int n = s.size(); rep(i,n) { if(s[i] == '(') { int pos = 0; for(int j = i + 1; j < n; j++) { if(s[j] == t[pos % 3]) pos++; if(s[j] == ')' && pos >= 3) ans++; } } } return ans; }; cout << calc("^^*") << " " << calc("*^^") << endl; }