10343: 黑白图像

Memory Limit:128 MB Time Limit:1.000 S
Judge Style:Text Compare Creator:
Submit:3 Solved:0

Description

输入一个n*n的黑白图像(1表示黑色,0表示白色),任务是统计其中八连块的个数。如果两个黑格子有公共边或者公共顶点,就说它们属于同一个八连块。如图所示的图形有3个八连块。

            

Input

1行输入一个正整数nn700),此后输入n行,每行是由n01组成的字符串。

Output

输出八连块的个数。

Sample Input Copy

6
100100
001010
000000
110000
111000
010100

Sample Output Copy

3