use std::io::*; fn main() { let mut s: String = String::new(); std::io::stdin().read_to_string(&mut s).ok(); let mut itr = s.trim().split_whitespace(); let n: usize = itr.next().unwrap().parse().unwrap(); let grid: Vec> = (0..n) .map(|_| itr.next().unwrap().chars().collect()) .collect(); let mut m = Vec::new(); for i in 0..n { for j in i + 1..n { if grid[i][j] == '-' { m.push((i, j)); } } } let mut ans = 10; for bit in 0..(1 << m.len()) { let mut now = grid.clone(); let mut point = Vec::new(); let mut rank = Vec::new(); for i in 0..m.len() { if bit >> i & 1 == 1 { now[m[i].0][m[i].1] = 'o'; now[m[i].1][m[i].0] = 'x'; } else { now[m[i].1][m[i].0] = 'o'; now[m[i].0][m[i].1] = 'x'; } } for i in 0..n { let mut p = 0; for j in 0..n { if i != j { if now[i][j] == 'o' { p += 1; } } } point.push((p, i)); rank.push(p); } point.sort_by(|a, b| b.0.cmp(&a.0)); let mut b = rank.clone(); b.sort(); b.reverse(); b.dedup(); let mut c = std::collections::HashMap::new(); for i in 0..b.len() { c.insert(b[i], i); } for i in 0..n { if point[i].1 == 0 { ans = std::cmp::min(ans, c[&point[i].0] + 1); } } } println!("{}", ans); }