#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

char fi[6][6];
char pi[6][6];

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin >> fi[i][j];
        }
    }
    int res=n;
    int m=n*(n-1)/2;
    for(int i=0;i<(1<<m);i++){
        bool ok=1;
        int id=0;
        for(int j=0;j<n;j++){
            for(int k=0;k<j;k++){
                if((1<<id)&i){
                    pi[j][k]='o';
                    pi[k][j]='x';
                    if(fi[j][k]=='o'||fi[j][k]=='-'){}
                    else ok=0;    
                }
                else{
                    pi[j][k]='x';
                    pi[k][j]='o';
                    if(fi[j][k]=='x'||fi[j][k]=='-'){}
                    else ok=0;
                }
                id++;
            }
        }
        if(ok){
            vector<int> win;
            for(int j=0;j<n;j++){
                int cnt=0;
                for(int k=0;k<n;k++){
                    if(pi[j][k]=='o')cnt++;
                }
                win.push_back(cnt);
            }
            int one=win[0];
            sort(win.begin(), win.end());
            win.erase(unique(win.begin(), win.end()),win.end());
            int ju=1;
            for(auto p:win){
                if(p>one)ju++;
            }
            res=min(res,ju);
        }
    }
    printf("%d\n",res );
}