#include #include const std::string ls = "^^*$", rs = "*^^$"; void solve() { std::string s; std::cin >> s; int n = s.length(); int l = 0, r = 0; for (int i = 0; i < n; ++i) { if (s[i] != '(') continue; int li = 0, ri = 0; for (int j = i + 1; j < n; ++j) { if (s[j] == ls[li]) ++li; if (s[j] == rs[ri]) ++ri; if (s[j] == ')') { if (li == 3) ++l; if (ri == 3) ++r; } } } std::cout << l << " " << r << std::endl; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); solve(); return 0; }