#! /usr/bin/env python3 def main(): S = input() l = [] cnt = 0 lans = rans = 0 for i in range(len(S)): if S[i] == '(': l += [2] elif S[i] == ')': lans += cnt elif S[i] == '^': l = [x-1 for x in l] elif S[i] == '*': d = len(l) l = [x for x in l if x > 0] cnt += d - len(l) l = [] cnt = 0 S = S[::-1] for i in range(len(S)): if S[i] == ')': l += [2] elif S[i] == '(': rans += cnt elif S[i] == '^': l = [x-1 for x in l] elif S[i] == '*': d = len(l) l = [x for x in l if x > 0] cnt += d - len(l) print(lans, rans) if __name__ == '__main__': main()