#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <functional>
#include <complex>
#include <queue>
#include <stack>
#include <cmath>
#include <cassert>
#include <tuple>
using namespace std;
typedef long long LL;
typedef complex<double> CMP;

typedef int           vert;
typedef vert          edge;
typedef vector<edge>  edges;
typedef vector<edges> graph;

bool augment( graph& G, int v, vector<vert>& matchTo, bool visited[] )
{
	for(int i=0; i<G[v].size(); ++i) {
		vert u = G[v][i];
		if( visited[u] ) continue;
		visited[u] = true;

		if( matchTo[u]<0 || augment(G, matchTo[u], matchTo, visited) )
			{ matchTo[v]=u, matchTo[u]=v; return true; }
	}
	return false;
}

template<int NV>
int biMatch( graph& G, int L ) // [0,L):left, [L,?):right
    // only left->right edges are used during computation
{
	vector<vert> matchTo(G.size(), -1);
	int ans = 0;
	for(vert v=0; v<L; ++v) {
		bool visited[NV] = {};
		if( augment(G, v, matchTo, visited) )
			++ans;
	}
	return ans;
}

class FoxAndGo3 { public:
	int maxEmptyCells(vector <string> board)
	{
		const int N = board.size();

		vector< vector<int> > ID(N, vector<int>(N));
		int Nblank=0, Nwhite=0;
		for(int y=0; y<N; ++y)
		for(int x=0; x<N; ++x)
			if(board[y][x]=='.')
				Nblank++;
			else if(board[y][x]=='o')
				Nwhite++;
		int IDblank = 0, IDwhite = Nblank;
		for(int y=0; y<N; ++y)
		for(int x=0; x<N; ++x)
			if(board[y][x]=='.')
				ID[y][x] = IDblank++;
			else if(board[y][x]=='o')
				ID[y][x] = IDwhite++;

		const int dy[] = {-1,+1,0,0};
		const int dx[] = {0,0,-1,+1};
		graph G(Nblank+Nwhite);
		for(int y=0; y<N; ++y)
		for(int x=0; x<N; ++x)
			if(board[y][x]=='o')
				for(int d=0; d<4; ++d) {
					int yy = y+dy[d], xx = x+dx[d];
					if(0<=yy&&yy<N&&0<=xx&&xx<N&&board[yy][xx]=='.')
						G[ID[yy][xx]].push_back(ID[y][x]);
				}
		return Nblank + Nwhite - biMatch<2500>(G, Nblank);
	}
};

// BEGIN CUT HERE
#include <ctime>
double start_time; string timer()
 { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v)
 { os << "{ ";
   for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it)
   os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; }
void verify_case(const int& Expected, const int& Received) {
 bool ok = (Expected == Received);
 if(ok) cerr << "PASSED" << timer() << endl;  else { cerr << "FAILED" << timer() << endl;
 cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } }
#define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock();
#define END	 verify_case(_, FoxAndGo3().maxEmptyCells(board));}
int main(){

CASE(0)
	string board_[] = {"o.o",
 ".o.",
 "o.o"};
	  vector <string> board(board_, board_+sizeof(board_)/sizeof(*board_)); 
	int _ = 5; 
END
CASE(1)
	string board_[] = {"...",
 ".o.",
 "..."}
;
	  vector <string> board(board_, board_+sizeof(board_)/sizeof(*board_)); 
	int _ = 8; 
END
CASE(2)
	string board_[] = {"xxxxx",
 "xxoxx",
 "xo.ox",
 "xxoxx",
 "xxxxx"}
;
	  vector <string> board(board_, board_+sizeof(board_)/sizeof(*board_)); 
	int _ = 4; 
END
CASE(3)
	string board_[] = {".xox.",
 ".o.ox",
 "x.o.o",
 "ox.ox",
 ".ox.."}
 ;
	  vector <string> board(board_, board_+sizeof(board_)/sizeof(*board_)); 
	int _ = 12; 
END
CASE(4)
	string board_[] = {"o.o.o",
 ".ox..",
 "oxxxo",
 "..x..",
 "o.o.o"}
;
	  vector <string> board(board_, board_+sizeof(board_)/sizeof(*board_)); 
	int _ = 12; 
END
CASE(5)
	string board_[] = {"...",
 "...",
 "..."};
	  vector <string> board(board_, board_+sizeof(board_)/sizeof(*board_)); 
	int _ = 9; 
END
/*
CASE(6)
	string board_[] = ;
	  vector <string> board(board_, board_+sizeof(board_)/sizeof(*board_)); 
	int _ = ; 
END
CASE(7)
	string board_[] = ;
	  vector <string> board(board_, board_+sizeof(board_)/sizeof(*board_)); 
	int _ = ; 
END
*/
}
// END CUT HERE
