import qualified Data.ByteString.Char8 as B
import Control.Monad
import Data.List
import qualified Data.Vector as V

t2 [a,b]=(a-1,b-1)
main=do
    [n,m] <- map read.words<$>getLine
    xys <- V.replicateM m $ t2.unfoldr (B.readInt.B.dropWhile(<'!'))<$>B.getLine
    print $ g n xys

g n xys = V.maximum v where
    ve = V.accumulate (flip (:)) (V.replicate n []) xys
    v = V.generate n m
    m i = (+1) $ maximum $ ((-1):) $ map (v V.!) (ve V.! i) 