class UF:
    def __init__(self, n):
        self.p = [-1]*n; self.c = [0]*n
    def f(self, x):
        if self.p[x] < 0: return x
        else: self.p[x] = self.f(self.p[x]); return self.p[x]
    def u(self, x, y):
        x = self.f(x); y = self.f(y)
        if -self.p[x] < -self.p[y]: x, y = y, x
        self.c[x] = max(self.c[x], self.c[y])+1
        if x == y: return
        self.p[x] += self.p[y]; self.p[y] = x
    def s(self, x, y): return self.f(x) == self.f(y)
n, m = map(int, input().split())
uv = [tuple(map(int, input().split())) for _ in range(m)]
uf = UF(n)
for u, v in uv[::-1]: uf.u(u-1, v-1)
print(uf.c[uf.f(0)])