from itertools import groupby n, *a = map(int, open(0).read().split()) g = [len(list(g)) for k, g in groupby(a)] ans1 = ans2 = 0 for i, v in enumerate(g): if i % 2: ans1 += v ans2 += max(v - 2, 0) else: ans1 += max(v - 2, 0) ans2 += v print(max(ans1, ans2))