# Fill Input input = "" try: with open("01.txt", 'r', encoding='utf-8') as file: input += file.read() except Exception as e: print(f"An error occurred: {e}") # Result res1, res2 = 0, 0 for i in range(len(input)): match input[i]: case '(': res1 += 1 case ')': res1 -= 1 if res1 < 0 and res2 == 0: res2 = i+1 print(res1, res2)