import Control.Monad
import Data.Foldable
import Data.List

sportsnum :: Int-> [[Int]]-> [(Int,Int)]
sportsnum n ass = map (\x -> (x,length $ elemIndices x $map head ass)) [1..n]

cmpsnd :: (Int,Int)->(Int,Int)->Ordering
cmpsnd a b = compare (snd a) (snd b)

maxsport0 :: Int -> [[Int]]->(Int,Int)
maxsport0 n ass =maximumBy cmpsnd $ sportsnum n ass

kill n ass = map (delete n) ass

solverpre acc n []:_ = acc
solverpre acc n ass = solverpre (n2:acc) n $kill n1 ass
    where (n1,n2) = maxsport0 n ass

solver n ass = minimum $ solverpre [] n ass


main :: IO ()
main = do
    [n, m] <- map read . words <$> getLine 
    ass <- replicateM n $ map read . words <$> getLine ::IO [[Int]]
    putStrLn $ show $ solver n ass

