def min_operations(s): n = len(s) operations = 0 balance = 0 for i in range(n): if s[i] == '0': balance += 1 else: balance -= 1 if balance < 0: operations += 1 balance += 2 return operations