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