#include<iostream>

using namespace std;

int field[12][12];
int came[12][12];
int islands;

void checker(int X,int Y)
{
	if(field[Y][X] == 1 && came[Y][X] == 0)
	{
		came[Y][X] = 1;
		if(X!=0)
		{
			checker(X-1,Y);
		}
		if(Y!=0)
		{
			checker(X,Y-1);
		}
		if(X!=11)
		{
			checker(X+1,Y);
		}
		if(Y!=11)
		{
			checker(X,Y+1);
		}		
	}
}

int main()
{
	while (for(int a = 0;a<12;a++)
	{
		cin >> field[a];
	})
	{
		for(int y = 0;x<12;x++)
		{
			for(int x = 0;y<12;y++)
			{
				if(field[y][x] == 1 && came[y][x] == 0)
				{
					island++;
					checker(x,y);
				}
			}
		}
		
		cout << islands << endl;

		for(int y = 0;y<11;y++)
		{
			for(int x = 0;x<11;x++)
			{
				came[y][x] = 0;
			}
		}
		
		islands = 0;
	}

	return 0;
}