readInt :: IO [Int]
readInt = map read . words <$> getLine

readIntlines :: Int -> IO [[Int]]
readIntlines n = map (map read . words) <$> replicateM n getLine

main :: IO ()
main = do
    [n, m] <- readInt
    ab <- readIntlines m >>= (\xs -> return [(x, y) | [x,y] <- xs])
    print $ solve ab
    return ()

solve :: [(Int, Int)] -> Int
solve xs = let groups = groupBy (\x y -> fst x == fst y) . sortOn fst $ xs
               fl = S.fromList
               groupset = map (foldl' (\acc (x, y) -> S.union acc (fl [x, y])) $ fl []) groups
            in maximum $ map S.size $ f groupset []
              where
                f [] newset     = newset
                f (y:ys) newset = f ys (set y newset)

set :: S.Set Int -> [S.Set Int] -> [S.Set Int]
set y gs = let (ts, fs) = partition (\c -> or $ S.map (`S.member` c) y) gs
            in if null ts
                  then y : fs
                  else S.unions (y : ts) : fs