with open ("input.txt", "r") as myfile:
  data=myfile.read()

count = 0
opened = 0
closed = 0

for char in data:

  count+=1
  if char == '(':
    opened+=1
  if char == ')':
    closed+=1

  if (opened-closed) == -1:
    print count

c3e0c27c847fec74e6796e22622da1859455450b
with open ("input.txt", "r") as myfile:
  data=myfile.read()

count = 0
opened = 0
closed = 0

for char in data:

  count+=1
  if char == '(':
    opened+=1
  if char == ')':
    closed+=1

  if (opened-closed) == -1:
    print count
