n = 7000 f = 0 instructions = input() ins = list(instructions) for i in range(n): if ins[i] == "(": f += 1 else: f -= 1 print(f)