program find_symmetries
  implicit none
  integer :: n, s(600,600), m, i, j
  character(300) :: t
  s = 0
  read(*,*) n
  do i = 1, n
    read(*,*) t
    t = trim(adjustl(t))
    do j = 1, n
      s(i,j) = ichar(t(j:j))-97
    end do
    s(i,n+1:2*n) = s(i,1:n)
    s(i+n,1:2*n) = s(i,1:2*n)
  end do
  m = 0
  do i = 0, n-1
    do j = 0, n-1
      if (sum(abs(s(1+i:n+i,1+j:n+j)-transpose(s(1+i:n+i,1+j:n+j)))).eq.0) m = m + 1
    end do
  end do
  write(*,'(i0)') m
  stop
end program find_symmetries