fun main(args: Array<String>) {
  val N = readLine()!!.toInt()
  val S = generateSequence { readLine()!! }.take(N).toList()
  val T = Array(2*N) { S[it % N ].repeat(2) }.toList()
  val tb = Array(2*N) { IntArray(2*N) }

  for(i in 0 until 2*N) {
    for(j in 0 until 2*N) {
      if(i == 0 || j == 0) tb[i][j] = 1
      else {
        val k = (0 .. Math.min(i, j)).find { T[i][j-it] != T[i-it][j] } ?: Math.min(i, j)
        tb[i][j] = Math.min(tb[i-1][j-1] + 1, k)
      }
    }
  }

  println((N until 2*N).map{ i -> (N until 2*N).count{ j -> tb[i][j] >= N } }.sum())
}