https://www.acmicpc.net/problem/11899
import sys
input = sys.stdin.readline
str = input().rstrip('\n')
stack = []
for i in str:
if not stack:
stack.append(i)
else:
if i == '(':
stack.append(i)
elif i == ')' and stack[-1] == '(':
stack.pop()
elif i == ')' and stack[-1] == ')':
stack.append(i)
print(len(stack))
글 잘 봤습니다.