//bcw0x1bd2 {{{
#include<bits/stdc++.h>
#include<unistd.h>
using namespace std;
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define SZ(x) ((int)((x).size()))
#define ALL(x) begin(x),end(x)
#define REP(i,x) for (int i=0; i<(x); i++)
#define REP1(i,a,b) for (int i=(a); i<=(b); i++)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;

#ifdef DARKHH
#define FILEIO(name)
#else
#define FILEIO(name) \
  freopen(name".in", "r", stdin); \
  freopen(name".out", "w", stdout);
#endif

#ifdef DARKHH
template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
  int c=0;
  while ( *s!=',' || c!=0 ) {
    if ( *s=='(' || *s=='[' || *s=='{' ) c++;
    if ( *s==')' || *s==']' || *s=='}' ) c--;
    cerr<<*s++;
  }
  cerr<<"="<<head<<", ";
  _dump(s+1,tail...);
}

#define dump(...) do { \
  fprintf(stderr, "%s:%d - ", __PRETTY_FUNCTION__, __LINE__); \
  _dump(#__VA_ARGS__, __VA_ARGS__); \
} while (0)

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
  s<<"[";
  for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
  s<<"]";
  return s;
}

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T, size_t N>
ostream& operator <<( ostream &s, const array<T,N> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }
#else
#define dump(...)
#endif
// }}}
// Let's Fight! ~OAO~~

const int INF = 1029384756;

int N,mp[514][514],arr[514][514];

void go(int i, int j) {
  static int c[514];
  REP(k,N) c[k] = arr[i][k];
  REP(k,N) arr[k][j] = c[k];
}
void dd() {
  REP(i,N) {
    REP(j,N) cout<<(arr[i][j]?'#':'.');
    cout<<endl;
  }
}
int solve(int base) {
  REP(i,N) REP(j,N) arr[i][j] = mp[i][j];
  int tot = 0;
  REP(i,N) REP(j,N) tot += arr[i][j];
  if (!tot) return INF;

  int res = 0;
  if (!arr[base][base]) {
    int b = -1;
    REP(j,N) if (arr[j][base]) {
      b = j;
      break;
    }
    if (b == -1) {
      go(base,base);
      b = base;
      res++;
    }
    REP(j,N) if (arr[j][base]) {
      b = j;
      break;
    }
    assert(b != -1);
    go(b,base);
    res++;
  }
  REP(i,N) {
    if (arr[base][i] == 0) {
      int b = -1;
      REP(j,N) if (arr[j][base]) {
        b = j;
        break;
      }
      if (b == -1) return INF;
      go(b,i);
      res++;
    }
  }
  REP(j,N) {
    int b = -1;
    REP(i,N) {
      if (arr[i][j] == 0) {
        b = j;
        break;
      }
    }
    if (b != -1) res++;
    go(base,b);
  }
  REP(i,N) REP(j,N)
    assert(arr[i][j]);
  return res;
}
int main() {
  IOS;
  int T = 1;
  while (cin>>N) {
    REP(i,N) {
      string s;
      cin>>s;
      REP(j,N) mp[i][j] = (s[j] == '#');
      //if (T == 336) cout<<s<<endl;
    }
    //if (T == 336) break;
    T++;

    int ans = INF;
    REP(i,N) {
      ans = min(ans, solve(i));
    }
    if (ans == INF) ans = -1;
    cout<<ans<<endl;
  }

  return 0;
}



Measured memory_bytes: 2304