23 lines
318 B
Python
23 lines
318 B
Python
|
from lib import *
|
||
|
|
||
|
data = open(0).read()
|
||
|
|
||
|
part_2 = True
|
||
|
|
||
|
floor = 0
|
||
|
for i, c in enumerate(data):
|
||
|
if c == "(":
|
||
|
floor += 1
|
||
|
elif c == ")":
|
||
|
floor -= 1
|
||
|
else:
|
||
|
print(c)
|
||
|
assert False
|
||
|
|
||
|
if part_2 and floor == -1:
|
||
|
print(i + 1)
|
||
|
break
|
||
|
|
||
|
if not part_2:
|
||
|
print(floor)
|