import Data.List f::Int->String->[(String,Int)]->Int f n ans []=length(ans)-2 f n ans ((a,b):xs) |n<=b=f b a xs |otherwise=f n ans xs main = do e<-getLine es<-getContents let xs=group $ sort $ lines es ys=zip (map head xs) (map length xs) print $ f 0 "" ys