https://www.acmicpc.net/problem/4889
import sys
input = sys.stdin.readline
ans = []
while True:
res = 0
stack = []
str = input().rstrip('\n')
if '-' in str:
break
for i in str:
if i == '{':
stack.append(i)
elif i == '}':
if not stack:
res += 1
stack.append('{')
else:
stack.pop()
res += (len(stack)//2)
ans.append(res)
for i in range(len(ans)):
print(i+1, '. ', ans[i], sep='')