#include<algorithm> #include<iostream> usingnamespacestd; int n, pre[20]; char s[20][20]; intmain(){ while (cin >> n) { for (int i = 0; i < n; i++) cin >> s[i], pre[i] = i; int res = 1e9; do { int sum = 0; for (int i = 0; i < n; i++) for (int j = i + 1; j < n; j++) sum += s[pre[j]][pre[i]] & 1; res = min(res, sum); } while (next_permutation(pre, pre + n)); cout << res << endl; } return0; }