| ps | |
|---|---|
| 링크 | acmicpc.net/… | 
| 출처 | BOJ | 
| 문제 번호 | 11899 | 
| 문제명 | 괄호 끼워넣기 | 
| 레벨 | 실버 3 | 
| 분류 | 
 괄호문자열  | 
	
| 시간복잡도 | O(n) | 
| 인풋사이즈 | n<=50 | 
| 사용한 언어 | Python 3.13 | 
| 제출기록 | 32412KB / 40ms | 
| 최고기록 | 32ms | 
| 해결날짜 | 2025/02/16 | 
"""Solution code for "BOJ 11899. 괄호 끼워넣기".
- Problem link: https://www.acmicpc.net/problem/11899
- Solution link: http://www.teferi.net/ps/problems/boj/11899
"""
def main():
    S = input()
    score = 0
    min_score = min(score := score + (1 if x == '(' else -1) for x in S)
    print(score - 2 * min(0, min_score))
if __name__ == '__main__':
    main()