#!/usr/bin/python3 file = [i.rstrip() for i in open("input").readlines()] j = 0 count = 0 for i in file[0]: if i == "(": j += 1 elif i == ")": j -= 1 count += 1 if j == -1: print("fin: count = " + str(count)) exit() print(j)