def min_operations_to_good_string(n, s): operations = 0 balance = 0 # difference: ones - zeros for char in s: if char == '1': balance += 1 else: # char == '0' balance -= 1 if balance < 0: operations += 1 balance += 2 # we flip this '0' to '1', so net +2 to balance print(operations) # Input reading if __name__ == "__main__": n = int(input()) s = input().strip() min_operations_to_good_string(n, s)