import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); char[] arr = sc.next().toCharArray(); int length = arr.length; ArrayList openIdxes = new ArrayList<>(); ArrayList closeIdxes = new ArrayList<>(); TreeSet asterIdxes = new TreeSet<>(); int[] eyeCount = new int[length]; for (int i = 0; i < length; i++) { switch (arr[i]) { case '(' : openIdxes.add(i); break; case ')' : closeIdxes.add(i); break; case '*' : asterIdxes.add(i); break; case '^' : eyeCount[i]++; break; } } if (openIdxes.size() == 0 || closeIdxes.size() == 0) { System.out.println("0 0"); return; } asterIdxes.add(0); asterIdxes.add(length - 1); for (int i = 1; i < length; i++) { eyeCount[i] += eyeCount[i - 1]; } int left = 0; int right = 0; int leftCount = 0; while (true) { boolean endflag = false; while (true) { int idx = asterIdxes.ceiling(openIdxes.get(left)); if (eyeCount[closeIdxes.get(right)] - eyeCount[idx] >= 2) { leftCount += closeIdxes.size() - right; break; } right++; if (right >= closeIdxes.size()) { endflag = true; break; } } if (endflag) { break; } left++; if (left >= openIdxes.size()) { break; } } left = 0; right = 0; int rightCount = 0; while (true) { boolean endflag = false; while (true) { int idx = asterIdxes.floor(closeIdxes.get(right)); if (eyeCount[idx] - eyeCount[openIdxes.get(left)] >= 2) { rightCount += closeIdxes.size() - right; break; } right++; if (right >= closeIdxes.size()) { endflag = true; break; } } if (endflag) { break; } left++; if (left >= openIdxes.size()) { break; } } System.out.println(rightCount + " " + leftCount); } }