#include <stdio.h>
#include <fstream>
#include <string>
#include <stdlib.h>
using namespace std;


char piece[10][10];
char grid[15][15];
int a,b,c,temp,great,cct;
int main()
{
	char com[3];
	bool check;
	FILE * infile;
	infile = fopen ("DATA5.txt" , "r");
	ofstream outfile;
	outfile.open("OUT5.txt", ios::out);
	for (a=1; a<=5; a++)
	{
		for (b=0; b<4; b++)
		{
			fgets (piece[b] , 5 , infile);
			fgets (piece[b+1] , 5 , infile);
		}
		for (c=0; c<6; c++)
		{
			fgets (grid[c] , 11 , infile);
			fgets (piece[c+1] , 5 , infile);
		}
		great=0;
		for (b=0; b<6; b++)
		{
			temp=0;
			for (c=0; c<10; c++)
			{
				com[0]=grid[b][c];
				com[1]='\0';
				if (strcmp(com,".") == 0)
					temp++;
			}
			if (temp==4)
			{
				cct=1;
				for (c=b+1; c<6; c++)
					if (strcmp(grid[c],"##########")==0)
						cct++;
				if (cct>great)
					great=cct;
				break;
			}
			else
			{
				if (temp==3)
				{
					cct=1;
					temp=0;
					for (c=0; c<10; c++)
					{
						com[0]=grid[b+1][c];
						com[1]='\0';
						if (strcmp(com,".") == 0)
							temp++;
					}
					if (temp==1)
						cct++;
					for (c=b+2; c<6; c++)
						if (strcmp(grid[c],"##########")==0)
							cct++;
					if (cct>great)
						great=cct;
					break;
				}
				else
				{
					if (temp==2)
					{
						temp=0;
						cct=1;
						for (c=0; c<10; c++)
						{
							com[0]=grid[b+1][c];
							com[1]='\0';
							if (strcmp(com,".") == 0)
								temp++;
						}
						if (temp==2)
							cct++;
						if (temp==1)
							cct+=2;
						for (c=b+2; c<6; c++)
							if (strcmp(grid[c],"##########")==0)
								cct++;
						if (cct>great)
							great=cct;
						break;
					}
					if (temp==1)
					{
						temp=0;
						cct=1;
						for (c=0; c<10; c++)
						{
							com[0]=grid[b+1][c];
							com[1]='\0';
							if (strcmp(com,".") == 0)
								temp++;
						}
						if (temp==1)
							cct++;
						if (b+2>6)
							break;
						for (c=0; c<10; c++)
						{
							com[0]=grid[b+2][c];
							com[1]='\0';
							if (strcmp(com,".") == 0)
								temp++;
						}
						if (b+3>6)
							break;
						if (temp==1)
							cct++;
							for (c=0; c<10; c++)
						{
							com[0]=grid[b+3][c];
							com[1]='\0';
							if (strcmp(com,".") == 0)
								temp++;
						}
						if (b+4>6)
							break;
						if (temp==1)
							cct++;
						for (c=0; c<10; c++)
						{
							com[0]=grid[b+4][c];
							com[1]='\0';
							if (strcmp(com,".") == 0)
								temp++;
						}
						if (temp==1)
							cct++;
						for (c=b+2; c<6; c++)
							if (strcmp(grid[c],"##########")==0)
								cct++;
							
				if (cct>great)
					great=cct;
				break;
					}
				}

			}
		}
		outfile << great << "\n";
			
	}
	return 0;
}

