import java.io.*; import java.util.*; class Main239 { public static void out (Object o) { System.out.println(o); } public static int solve (String[][] memo) { int ret = -1; for (int i = 0; i < memo.length; i++) { for (int j = 0; j < memo.length; j++) { String s = memo[j][i]; if (!s.equals("nyanpass") && !s.equals("-")) break; if (j == memo.length - 1) { if (ret != -1) return -1; ret = i + 1; } } } return ret; } public static void main (String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); String[][] memo = new String[n][n]; for (int i = 0; i < n; i++) { String[] line = br.readLine().split(" "); for (int j = 0; j < n; j++) { memo[i][j] = line[j]; } } out(solve(memo)); } }