#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <queue>
#include <cassert>

using namespace std;

//------------------------------------------------------------------------------------------------------------------------
// CONSTANTS
//------------------------------------------------------------------------------------------------------------------------

#define PI          3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803   /* all from memory! */
#define PHI         1.6180339887498948482045868343656   /* = (sqrt(5)+1)/2  */
#define MAXINT      0x7fffffff                          /* for a signed integer */
#define EPSILON     0.00000001                          /* for floating-point value comparison */
#define MAXDOUBLE   1.79769313486231570e+308

#define NORTH       0
#define EAST        1
#define SOUTH       2
#define WEST        3

#define MS(a,b)     memset(a, b, sizeof(a))
#define FOR(a,b,c)  for (a = (b); a < (c); ++a)

const int fact[] = { 1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800, 479001600 }; // up to 12!
const int month[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};  // lengths of each month


//------------------------------------------------------------------------------------------------------------------------
// GLOBAL VARIABLES
//------------------------------------------------------------------------------------------------------------------------

int dc[] = {  0,  1,  0, -1 };
int dr[] = { -1,  0,  1,  0 };
int cmax = -MAXINT;
int cmin = MAXINT;
string object[5];


//------------------------------------------------------------------------------------------------------------------------
// FUNCTIONS/CLASS DEFINITIONS
//------------------------------------------------------------------------------------------------------------------------

/*
void killEmpty(int obj[5])
{
    for (i = 0; i < 5; ++i)
    {

    }
}*/

void recur(int obj[5])
{
    // fit

}




//------------------------------------------------------------------------------------------------------------------------
// MAIN PROGRAM EXECUTION
//------------------------------------------------------------------------------------------------------------------------
int main()
{
    ifstream fin("data5.txt");
    ofstream fout("out5.txt");
    int i = 0, j = 0, k = 0, l;
    int num, n1, n2, n3;
    string str;
    string inputStr = "0";


    for (i = 0; i < 5; ++i)
    {
        int item[30][5];
        memset(item, 0,sizeof(item));
        fin >> num;
        getline(fin,str);
        int hashes = 0;
        int bins = 0;
        for (j = 0; j < num; ++j)
            {
                int cur = 0;
                k = 0;
                do
                {
                    getline(fin,str);
                    if (str == "") break;

                    //cout << str; cin.get();
                    for (l = 0; l < str.length(); ++l)
                    {
                        hashes += (str[l]=='#');
                        cur += (str[l]=='#');
                        item[j][k] |= (str[l]=='#')<<l;

                    }
                    //cout << j << " " << k << " " << item[j][k]; cin.get();

                    ++k;
                } while (1);
                if (cur == 25)
                {
                    hashes-=25;
                    bins++;
                }
            }

        fout << hashes/18 + bins << endl;
    }










    return 0;
}




