#
# Setting Go Stones
#
while (n=gets.to_i)!=0
  stones=Array.new(n)
  stones[0]=gets.to_i
  1.upto(n-1) do |i|
    c=gets.to_i
    if i.odd?
      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[i]=c
  end
  puts stones.count(0)
end