object Main extends App{
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val s = Array.fill(n)(sc.next).map(_.toCharArray())
  def getnum(i:Int) = {
    if (i>=0){
      i
    } else {
      n+i
    }
  }
  val result = (0 until n).map(a => {
    (0 until n).count(b => {
      (0 until n).forall(i=>{
        (0 until n).forall(j=>{
          s(getnum(i-a))(getnum(j-b))==s(getnum(j-a))(getnum(i-b))
        })
      })
    })
  }).sum
  println(result)
}