import Control.Monad
import Data.List

check n l = sum $ map go [0..n-1]
  where
    cl offs = map (take n . drop offs . cycle) l
    go offs
      | transpose (cl offs) == (cl offs) = n
      | otherwise = 0

main = do
    n <- read <$> getLine
    l <- replicateM n getLine
    print $ check n l
