def min_operations_to_good_string(S): N = len(S) ones = S.count('1') zero_blocks = 0 i = 0 while i < N: if S[i] == '0': start = i while i < N and S[i] == '0': i += 1 length = i - start if length >= 2: zero_blocks += 1 else: i += 1 ops = 0 while zero_blocks >= ones: ops += 1 zero_blocks -= 1 ones += 1 return ops if __name__ == "__main__": N = int(input()) S = input().strip() print(min_operations_to_good_string(S))