def bury(i,j)
  @map[i][j] = "0"
  [[0,1],[1,0],[0,-1],[-1,0]].each do |x,y|
    next if !(0..11).include?(i+x) || !(0..11).include?(j+y)
    bury(i+x,j+y) if @map[i+x][j+y]=="1"
  end
end

loop do
  @map = 12.times.map{ gets.chomp }
  cnt = 0
  12.times do |i|
    12.times do |j|
      if @map[i][j]=="1"
        cnt += 1
        bury(i,j)
      end
    end
  end
  puts cnt
  break if gets.nil?
end