n = int(input()) s = input() count0 = 0 count1 = 0 operations = 0 for c in s: if c == '0': count0 += 1 else: count1 += 1 if count0 > count1: operations += 1 count0 -= 1 # この0を1に変えたと仮定 print(operations)