n = int(input()) s = input() score = 0 operations = 0 for c in s: if c == '1': score += 1 else: score -= 1 if score < 0: operations += 1 score += 2 # この0を1に変えたとしてスコアを補正 print(operations)