#include<iostream>
#include<queue>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<utility>
#include<map>
#include<vector>

using namespace std;

typedef struct
{
  int c;
  int r;
  int l;
  int u;
  int t;
}Riku;

int check(Riku riku[18][18],int i,int j)
{
  riku[i][j].c=2;
  if(riku[i][j].r==1 && riku[i][j+1].c!=2) check(riku,i  ,j+1);
  if(riku[i][j].l==1 && riku[i][j-1].c!=2) check(riku,i  ,j-1);
  if(riku[i][j].u==1 && riku[i+1][j].c!=2) check(riku,i+1,j  );
  if(riku[i][j].t==1 && riku[i-1][j].c!=2) check(riku,i-1,j  );
  
  return 1;
}

int dfs(Riku riku[18][18])
{
  int n=15;
  int i=0,j=0;
  int t=0,y=0;
  int shima=0;

  for(i=3;i<n;i++)
    for(j=3;j<n;j++)
      if(riku[i][j].c==1)
        {
	  //	  printf("i=%d, j=%d\n",i-2,j-2);
          shima++;
          check(riku,i,j);
        }
  return shima;
}

void con(Riku riku[18][18],int i,int j)
{
  if(riku[i][j].c==1)
    {
      riku[i+1][j].t=1;
      riku[i-1][j].u=1;
      riku[i][j+1].l=1;
      riku[i][j-1].r=1;
    }
}

int main(void)
{
  int i=1;
  int j=1;
  int n=15;
  int shima=0;
  Riku riku[18][18]={};
  Riku erase={};

  while(1)
    {
      for(i=0;i<18;i++)
	for(j=0;j<18;j++)
	  riku[i][j]=erase;
      
      for(i=3;i<n;i++)
	for(j=3;j<n;j++)
	  {
	    scanf(" %c",&riku[i][j].c);
	    if(riku[i][j].c==EOF)return 0;
	    riku[i][j].c-='0';
	    con(riku,i,j);
	  }
      
      shima=dfs(riku);
      
      printf("%d\n",shima);
    }
  return 0;
}