import           Control.Monad
import           Data.List

main = do
    n <- readLn :: IO Int
    (s1:s) <- replicateM n getLine :: IO [String]
    let s1' = sort s1
    print $ length [1 | si <-s, (sort si == s1')]
