#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long

bool A[100][100];

int main() {
	int n;
	cin >> n;

	rep(i, n) rep(j, n) {
		string s;
		cin >> s;
		if (s == "nyanpass") A[i][j] = true;
		else if (s == "-") A[i][j] = true;
	}
	int cnt = 0,ans;
	rep(j, n) rep(i,n){
		if (A[i][j]) {
			if (i == n - 1) {
				cnt++;
				ans = j + 1;
			}
			continue;
		}
		else break;
	}

	if (cnt == 1) cout << ans << endl;
	else cout << -1 << endl;

	return 0;
}