using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.Text; using System.Text.RegularExpressions; using System.Linq; class Magatro { static int N = int.Parse(Console.ReadLine()); static char[][] s; static void Main() { s = new char[N][]; for(int i = 0; i < N; i++) { s[i] = Console.ReadLine().ToArray(); } /* for(int i = 0; i < N; i++) { if (s[0][i] == '-') { s[0][i] = 'o'; s[i][0] = 'x'; } } */ List L = new List(); for(int i = 0; i < N - 1; i++) { for(int j = i + 1; j < N; j++) { if (s[i][j] == '-') { L.Add(new XY(j, i)); } } } int loop = (int)Math.Pow(2, L.Count); int min = int.MaxValue; for(int i = 0; i < loop; i++) { int q = i; char[][] copy = s.ToArray(); for(int j = 0; j < L.Count; j++) { if (q % 2 == 1) { copy[L[j].Y][L[j].X] = 'o'; copy[L[j].X][L[j].Y] = 'x'; } else { copy[L[j].Y][L[j].X] = 'x'; copy[L[j].X][L[j].Y] = 'o'; } q /= 2; } min = Math.Min(min, J(copy)); } Console.WriteLine(min); } static int J(char[][] ss) { T[] Temp = new T[N]; for(int i = 0; i < N; i++) { Temp[i] = new T(i); } for(int i = 0; i < N; i++) { for(int j = 0; j < N; j++) { if (i == j) { continue; } if(ss[j][i]== 'o') { Temp[i].c++; } } } T[] copy = Temp.ToArray(); Array.Sort(copy, (a, b) => a.c.CompareTo(b.c)); int ans = 0; int m = int.MaxValue; for(int i = 0; i < N; i++) { if (m != copy[i].c) { ans++; m = copy[i].c; } if (copy[i].index == 0) { return ans; } } return -1; } } struct XY { public int X, Y; public XY(int x,int y) { X = x; Y = y; } } struct T { public int index, c; public T(int i) { c = 0; index = i; } }