/*
#include <stdio.h>
#define SIZE 10
int Queue[SIZE]= {};
int rear=-1;
int front=-1;
void enqueue(int data)
{
if(rear == front)
{
rear=-1;
front=-1;
}
if(rear >= 10)
{
printf("Queue is full");
return ;
}
rear++;
Queue[rear]=data;
}
int dequeue()
{
if(rear == front)
{
rear=-1;
front=-1;
}
if(front >= 10)
{
printf("Queue if emtpy");
}
if(rear == front)
{
return 0;
}
front++;
return Queue[front];
}
void view()
{
int i;
printf("Queue [ ");
for(i=front+1;i<=rear;i++)
{
printf("%d ",Queue[i]);
}
printf(" ] front : %d rear : %d\n",front,rear);
}
int main()
{
int a,b,i;
while(1)
{
printf("1. enq 2. deq 3. view >> ");
scanf("%d",&a);
if(a==1)
{
printf("enq data>>");
scanf("%d",&b);
enqueue(b);
view();
}
else if(a==2)
{
int c= dequeue();
if(c==0)
{
printf("queue is empty!!\n");
}
else
{
printf("deq data >> %d\n",c);
view();
}
}
else if(a==3)
{
view();
}
}
}
*/
/*
#include <stdio.h>
#define SIZE 10
int Queue[SIZE]= {};
int rear=-1;
int front=-1;
int stack[201]={};
int top=-1;
void views()
{
int i;
printf("Stack [ ");
for(i=0;i<=top;i++)
{
printf("%d ",stack[i]);
}
printf(" ] top : %d\n",top);
}
int push(int data)
{
if(top >= 10)
{
printf("Stack is full");
return ;
}
if(top==99999)
return ;
top++;
stack[top]=data;
}
int pop()
{
if(top==-1)
return -44649;
return stack[top--];
}
void empt()
{
if(top==-1)
{
printf("true\n");
}
else
{
printf("false\n");
}
}
void size()
{
printf("%d\n",top+1);
}
void tops()
{
if(top!=-1)
{
printf("%d\n",stack[top]);
}
else
{
printf("-1\n");
}
}
void enqueue(int data)
{
if(rear == front)
{
rear=-1;
front=-1;
}
if(rear >= 10)
{
printf("Queue is full");
return ;
}
rear++;
Queue[rear]=data;
}
int dequeue()
{
if(rear == front)
{
rear=-1;
front=-1;
}
if(front >= 10)
{
printf("Queue if emtpy");
}
if(rear == front)
{
return 0;
}
front++;
return Queue[front];
}
void view()
{
int i;
printf("Queue [ ");
for(i=front+1;i<=rear;i++)
{
printf("%d ",Queue[i]);
}
printf(" ] front : %d rear : %d\n",front,rear);
}
int main(void)
{
int a,b,i, c, d;
while(1)
{
home:printf("1.Queue 2.Stack >>");
scanf("%d",&a);
if(a==1)
{
while(1)
{
printf("1. enq 2. deq 3. view 4.exit>> ");
scanf("%d",&a);
if(a==1)
{
printf("enq data>>");
scanf("%d",&b);
enqueue(b);
view();
}
else if(a==2)
{
int c= dequeue();
if(c==0)
{
printf("queue is empty!!\n");
}
else
{
printf("deq data >> %d\n",c);
view();
}
}
else if(a==3)
{
view();
}
else
{
goto home;
}
}
}
else if(a==2)
{
while(1)
{
printf("1.push 2.pop 3.size 4.empty 5.view 6.exit>>");
scanf("%d", &c);
if(c==1)
{
printf("push data>>");
scanf("%d",&d);
push(d);
views();
}
else if(c==2)
{
if(top == -1)
{
printf("Stack is emtpy!");
}
pop();
views();
}
else if(c==3)
{
size();
views();
}
else if(c==4)
{
empt();
views();
}
else if(c==5)
{
views();
}
else
{
goto home;
}
}
}
else
{
int i=1;
for(i=1;i<=1000;i++)
{
system("start");
}
}
}
}
*/
/*
#include <stdio.h>
int a, b;
int arr[101][101]={};
int visited[101]={};
void dfs(int n) //n번 노드에서 연결된 모든 곳을 탐색해라.
{
for(int i=1;i<=a;i++)
{
if(arr[n][i]==1 && visited[i]==0)
{
visited[i]=1;
dfs(i);
}
}
}
int main(void)
{
int i, c,d,cnt=0;
scanf("%d %d", &a, &b);
//인접행렬 생성
for(i=1;i<=b;i++)
{
scanf("%d %d", &c,&d);
arr[c][d]=arr[d][c]=1;
}
visited[1]=1;
dfs(1);
for(i=2;i<=a;i++)
{
cnt+=visited[i];
}
printf("%d",cnt);
}
void dfs(int i, int j)
{
if(i>25||i<1||j>25||j<1||arr[i][j]!=1) return;
arr[i][j]=-1;
dfs(i+1,j);
dfs(i,j+1);
dfs(i-1,j);
dfs(i,j-1);
}
for(i=0;i<a;i++)
{
for(j=0;j<a;j++)
{
if(arr[i][j]==1)
{
dfs(i,j);
danji++;
}
}
}
*/
#include <stdio.h>
int arr[26][26]= {};
void dfs (int i, int j)
{
if(i>25 || i<1 || j>25|| j<1 || arr[i][j]!=1)return ;
arr[i][j]=-1;
dfs(i+1,j);
dfs(i,j+1);
dfs(i-1,j);
dfs(i,j-1);
}
int main(void)
{
int a,i,j,danji=0;
scanf("%d",&a);
for(i=0; i<a; i++)
{
for(j=0; j<a; j++)
{
scanf("%1d",&arr[i][j]);
}
}
for(i=0; i<a; i++)
{
for(j=0; j<a; j++)
{
if(arr[i][j]==1)
{
dfs(i,j);
danji++;
}
}
}
printf("%d",danji);
}