def min_operations_to_good_string(S): ones = S.count('1') operations = 0 while True: i = 0 found_bad_sequence = False while i < len(S): if S[i] == '0': start = i while i < len(S) and S[i] == '0': i += 1 length = i - start if length >= 2 and length >= ones: found_bad_sequence = True mid = start + length // 2 S = S[:mid] + '1' + S[mid+1:] ones += 1 operations += 1 break else: i += 1 if not found_bad_sequence: break return operations if __name__ == "__main__": N = int(input()) S = input().strip() print(min_operations_to_good_string(S))