#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e6 + 5;
const int INF = 0x3f3f3f3f;
const int mod = 998244353;
int lowbit(int x) { return x & (-x); }
int fast_power(int a, int b) {
  int x;
  for (x = 1; b; b >>= 1) {
    if (b & 1) x = 1ll * x * a % mod;
    a = 1ll * a * a % mod;
  }
  return x % mod;
}
pair<int, int> a[MAXN];
int ans[MAXN];
int fa[MAXN], head[MAXN], pre[MAXN], nxt[MAXN];
int find(int x) {
  if (fa[x] != x) fa[x] = find(fa[x]);
  return fa[x];
}
void merge(int x, int y) {
  int fa_x = find(x), fa_y = find(y);
  if (fa_x == fa_y) return;
  fa[fa_x] = fa_y;
}
void del(int i) {
  pre[nxt[i]] = pre[i];
  nxt[pre[i]] = nxt[i];
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i <= n; i++) {
    fa[i] = i;
    nxt[i] = i + 1;
    pre[i] = i - 1;
  }
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    a[2 * i - 1] = make_pair(x, y);
    a[2 * i] = make_pair(y, x);
  }
  sort(a + 1, a + 2 * m + 1);
  for (int i = 1, k = 1; i <= n; i++) {
    for (int j = nxt[0]; j <= n; j = nxt[j]) {
      while (a[k].first < i || a[k].first == i && a[k].second < j) k++;
      if (a[k].first == i && a[k].second == j) {
        k++;
        continue;
      }
      merge(j, i);
      if (find(j) == find(nxt[j])) del(j);
    }
  }
  for (int i = 1; i <= n; i++) ans[find(i)]++;
  sort(ans + 1, ans + n + 1);
  int res = 0;
  for (int i = 1; i <= n; i++)
    if (ans[i]) res++;
  printf("%d\n", res);
  for (int i = 1; i <= n; i++)
    if (ans[i]) printf("%d ", ans[i]);
  puts("");
  return 0;
}
