import Control.Monad

main = do
  n <- readLn
  ass <- replicateM n getLine
  print $ solve n ass

solve n ass
  | or hasblacks = minimum costs + length (filter id todos)
  | otherwise = -1
  where
  (todos,hasblacks) = foldr f (falses,falses) ass
  falses = replicate n False
  f as (todos,hasblacks) = (zipWith g todos as,zipWith h hasblacks as)
    where
    g a b = a || b=='.'
    h a b = a || b=='#'
  costs = g ass hasblacks
  g [] _ = []
  g (as:ass) (hasblack:hbs)
    | hasblack = whites : g ass hbs
    | otherwise = 1 + whites : g ass hbs
    where whites = length $ filter (=='.') as