def min_operations_to_good_string(N, S): # 0を1に変更する必要がある回数をカウント zero_count = 0 # 連続した0の数 ones_count = 0 # 1の数 operations = 0 # 操作回数 for i in range(N): if S[i] == '0': zero_count += 1 else: ones_count += 1 # 0の数が1の数を超えた場合、その差だけ0を1に変える if zero_count > ones_count: operations += zero_count - ones_count zero_count = ones_count # 差を解消し、0の数を1の数に合わせる return operations # 入力の処理 N = int(input()) S = input().strip() # 最小操作回数を求める print(min_operations_to_good_string(N, S))