import sys sys.setrecursionlimit(10 ** 8) N,M = map(int,input().split()) parent = [-1] * (N + 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:return False if parent[I] < parent[J]: I,J =J,I parent[J] += parent[I] parent[I] = J return True for _ in range(M): a,b = map(int,input().split()) unite(a - 1,b - 1) m = 0 for i in range(N + N): if parent[i] < 0: if -parent[i] > m: m = -parent[i] if m <= N: print(N) else: print(N + N - m)