import io.StdIn.{readInt, readLine}
object Main extends App {
  val n = readInt
  val glid = List.fill(n)(readLine.toList)

  println(solve(glid, 0))

  def solve(glid: List[List[Char]], count: Int) = {
    if (glid.forall(_.forall('.'.==))) -1
    else if (glid.exists(_.forall('#'.==))) count + n - glid.transpose.count(_.forall('#'.==))
    else if ((0 until n).exists(i => glid(i)(i) == '#')) 2 * n - (0 until n).filter(i => glid(i)(i) == '#').map(i => glid(i).count('#'.==)).max
    else 2 * n
  }
}
