use std::io::Read; fn j(c: Vec) -> bool { !c.contains(&'B') && c.iter().filter(|&&x| x == '.').count() == 1 } fn main() { let mut s = String::new(); std::io::stdin().read_to_string(&mut s).ok(); let c: Vec> = s.lines().skip(1).map(|l| l.chars().collect()).collect(); let n = c.len(); let mut a = 0; a += j((0..n).map(|i| c[i][i]).collect()) as u8; a += j((0..n).map(|i| c[i][n - i - 1]).collect()) as u8; for i in 0..n { a += j((0..n).map(|j| c[i][j]).collect()) as u8; a += j((0..n).map(|j| c[j][i]).collect()) as u8; } println!("{a}") }