#
# Setting Go Stones
#
while (n=gets.to_i)!=0
  stones=[]<<gets.to_i
  2.upto(n) do |i|
    c=gets.to_i
    if i.even?
      if stones[-1]!=c
        (stones.size-1).downto(0) do |j|
          if stones[j]!=c
            stones[j]=c
          else
            break
          end
        end
      end
    end
    stones<<c
  end
  puts stones.count(0)
end