def dfs(xy, mat)
  mat.delete(xy)
  i, j = xy.split.map(&:to_i)
  direc = [[1,0],[0,1],[-1,0],[0,-1]]
  direc.each{|dx,dy|
    next if i+dx < 0 || j+dy < 0 || i+dx > 11 || j+dy > 11
    key = "#{i+dx} #{j+dy}"
    mat = dfs(key,mat) if mat[key]
  }
  return mat
end

arr = readlines

while arr.size > 0
  mat = Hash.new
  12.times{|i|
    line = arr.shift
    a = line.chomp.split("")
    12.times{|j|
      mat["#{i} #{j}"] = 1 if a[j] == "1"
    }
  }
  count = 0
  while mat.size > 0
    xy = mat.keys[0]
    mat = dfs(xy,mat)
    count += 1
  end
  puts count
  arr.shift if arr.size > 1
end