$move = [[0, 1], [1, 0],[0, -1], [-1, 0]]
$map = []

def dfs(x , y)
	$map[x][y] = 0
	$move.each do |e|
		dfs(x + e[0], y + e[1]) if $map[x + e[0]][y + e[1]] == 1
	end
end

def solve
	result = 0

	12.times { $map << gets.split("").map(&:to_i) }

	12.times do |i|
		12.times do |j|
			if $map[i][j] == 1
				result += 1;
				dfs(i, j)
			end
		end
	end

	puts result
end

20.times do
	solve
	gets
	$map.clear
end