from collections import defaultdict, deque from heapq import heappush, heappop from itertools import permutations, accumulate import sys import math import bisect def LI(): return [int(x) for x in sys.stdin.readline().split()] def I(): return int(sys.stdin.readline()) def IR(n): return [I() for _ in range(n)] def LIR(n): return [LI() for _ in range(n)] sys.setrecursionlimit(1000000) mod = 1000000007 class UnionFind: __slots__ = ["par", "rank", "size"] def __init__(self, n): self.par = list(range(n)) self.rank = [0]*n self.size = [1]*n def root(self, x): if x == self.par[x]: return x self.par[x] = self.root(self.par[x]) return self.par[x] def unite(self, x, y): x = self.root(x) y = self.root(y) if self.rank[x] < self.rank[y]: self.par[x] = y self.size[y] += self.size[x] else: self.par[y] = x self.size[x] += self.size[y] if self.rank[x] == self.rank[y]: self.rank[x] += 1 return def main(): n,m = LI() edges = LIR(m) uf = UnionFind(n) f = [0]*n for a,b in reversed(edges): a -= 1 b -= 1 ra = uf.root(a) rb = uf.root(b) if ra != rb: uf.unite(a,b) f[uf.root(a)] = max(f[ra],f[rb])+1 else: f[ra] += 1 print(max(f)) return if __name__ == "__main__": main()