import sys
str = sys.stdin.readline()
sum = 0
list1=[]
list2=[]
for i in str:
if i == "[":
list1.append(i)
result = len(list1)
list2.append(result)
elif i == "]":
list1.pop()
print(max(list2))
deep = 0
counter = 0
input_str = input()
for ch in input_str:
if ch == "[":
counter += 1
if counter > deep:
deep = counter
elif ch == "]":
counter -= 1
print(deep)
# else: don't need to do anything
"""
括号配对
"""
if __name__ == "__main__":
s = input()
ans, tmp = 0, 0
for c in s:
if c == '[':
tmp += 1
ans = max(ans, tmp)
elif c == ']':
tmp -= 1
print(ans)