program row_to_column
  implicit none
  integer :: n, a(500,500) = 0, i, j, r, c = 0, x
  character(500) :: s
  read(*,*) n
  do i = 1, n
    read(*,*) s
    do j = 1, n
      if (s(j:j) == "#") a(i,j) = 1
    end do
  end do
  if (sum(a(1:n,1:n)) == 0) then
    write(*,'(i0)') -1
    stop
  end if
  do j = 1, n
    if (sum(a(1:n,j)) /= n) c = c+1
  end do
  r = n+1
  do i = 1, n
    x = n-sum(a(i,1:n))+1-a(i,i)
    r = min(r,x)
  end do
  write(*,'(i0)') r+c
end program row_to_column