import Control.Applicative
import Data.List

main = do
  n <- readLn :: IO Int
  s <- lines <$> getContents :: IO [[Char]]

  print $ sum $ map (\x -> if isSymmetrical x n then n else 0) (take n (iterate rotate s))


isSymmetrical :: [[Char]] -> Int -> Bool
isSymmetrical s n = and [s!!i!!j == s!!j!!i | i<-[0..n-1], j<-[i..n-1]]

rotate :: [a] -> [a]
rotate xs = last xs : init xs