import sys sys.setrecursionlimit(10 ** 8) N,M = map(int,input().split()) edge = [] for _ in range(M): u,v = map(int,input().split()) edge.append((u-1,v-1)) parent = [-1] * N def find(i): if parent[i] < 0: return i parent[i] = find(parent[i]) return parent[i] def unite(i,j): I = find(i) J = find(j) if I == J: parent[I] -= 1 return False t = min(parent[I],parent[J]) parent[I] = J parent[i] = J parent[J] = t - 1 return True def isSame(i,j): return find(i) == find(j) ans = 0 for u,v in reversed(edge): unite(u,v) ans = min(parent) print(-ans - 1)