#include <iostream>
#include <vector>
#include <string>
#include <set>

using namespace std;

int find_s(vector<vector<int>> & tb,int pos)
{
	int w = tb[0].size();
	int i = pos % w;
	int j = pos / w;
	if(tb[j][i] != j*w+i)
	{
		tb[j][i] = find_s(tb,tb[j][i]);
	}
	return tb[j][i];
}

void union_s(vector<vector<int>> & tb,int pos1,int pos2)
{
	int w = tb[0].size();
	int pr1 = find_s(tb,pos1);
	int pr2 = find_s(tb,pos2);
	tb[pr1/w][pr1%w] = pr2;
}

int main()
{
	while(!feof(stdin))
	{
		int w,h;
		vector<string> mp;
		for(int i = 0;i < 12;i++)
		{
			string str;
			cin >> str;
			if(str.size() < 12)
			{
				if(feof(stdin))
					return 0;
				i--;
				continue;
			}
			mp.push_back(str);
		}
		w = 12;
		h = 12;
		vector<vector<int>> tb;
		vector<vector<int>> tb2;
		for(int i = 0;i < h;i++)
		{
			vector<int> ary(w);
			vector<int> ary2(w);
			for(int j = 0;j < w;j++)
			{
				ary[j] = (mp[i][j] - '0');
				ary2[j] = i*w+j;
			}
			tb.push_back(ary);
			tb2.push_back(ary2);
		}
		for(int i = 0;i < h;i++)
		{
			for(int j = 1;j < w;j++)
			{
				if(tb[i][j-1] && tb[i][j])
				{
					union_s(tb2,i*w+j-1,i*w+j);
				}
			}
		}
		for(int i = 1;i < h;i++)
		{
			for(int j = 0;j < w;j++)
			{
				if(tb[i-1][j] && tb[i][j])
				{
					union_s(tb2,(i-1)*w+j,i*w+j);
				}
			}
		}
		set<int> pr;
		for(int i = 0;i < h;i++)
		{
			for(int j = 0;j < w;j++)
			{
				if(tb[i][j])
				{
					find_s(tb2,i*w+j);
				}
			}
		}
		for(int i = 0;i < h;i++)
		{
			for(int j = 0;j < w;j++)
			{
				if(tb[i][j])
				{
					pr.insert(find_s(tb2,i*w+j));
				}
			}
		}
		cout << pr.size() << endl;
	}
	return 0;
}