import scala.collection.mutable.MutableList

object Main extends App{
  
  import scala.io.StdIn._
  val n = readLine().toInt
  val strings = Array.tabulate(n){_ => readLine()}
  var suspects = MutableList[Tuple2[Int,Int]]()
  for (a <- 0 until n){
    for (b <- 0 until n){
      suspects += Tuple2(a, b)
    }
  }
  def isMatch(i:Int, a:Int, b:Int):Boolean = {
      for (j <- 0 until n){
        if (strings(i)(j) != strings((j + b + n - a) % n)((i + a + n - b) % n)){
          return false
        }
      }
      return true
  }
  for ( i <- 0 until n){
    suspects = suspects.filter{case (a, b) =>
      isMatch(i, a, b)
    }
  }
  println(suspects.size)
}