def min_operations_to_good_string(N, S): count_0 = 0 count_1 = 0 operations = 0 # 文字列を走査 for char in S: if char == '0': count_0 += 1 else: count_1 += 1 # 直前の文字が0で、今が0の時 if count_0 > count_1 and (len(S) > 1 and char == '0'): operations += 1 # 1つの操作で1つの0を1に変えたことにする count_1 += 1 # 0を1に変えたと仮定する count_0 -= 1 # その分、0のカウントを減らす return operations # 入力の読み込み N = int(input().strip()) S = input().strip() # 結果の出力 result = min_operations_to_good_string(N, S) print(result)