object Main extends App {
	val n = scala.io.StdIn.readInt
	val s = Array.ofDim[Char](n,n)
	val t = Array.ofDim[Char](n,n)

	for(i<-0 until n){
		s(i) = scala.io.StdIn.readLine.toList.toArray
	}

	var ans = 0

	for(i<-0 until n){
		for(j<-0 until n){
			for(k<-0 until n){
				t(j)(k) = s(j)((k+i)%n)
			}
		}

		ans += check()
	}

	println(ans * n)


	def check(): Int = {
		var flag = true

		for(i<-0 until n){
			for(j<-i+1 until n){
				if(t(i)(j) != t(j)(i)){
					flag = false
				}
			}
		}

		if(flag) return 1
		else return 0
	}
}