#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
struct E {
  int to, nxt;
} e[N << 1];
int n, m, head[N], cnt, l[N], r[N], ans[N], ans_cnt, fa[N];
bool b[N];
int Write[20], WRI;
void judge() {
  freopen(".in", "r", stdin);
  freopen(".out", "w", stdout);
}
int read() {
  int d = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') d = d * 10 + c - 48, c = getchar();
  return d * f;
}
void write(int x) {
  if (!x) {
    putchar('0');
    return;
  }
  if (x < 0) putchar('-'), x = -x;
  for (WRI = 1; x; x /= 10, WRI++) Write[WRI] = x % 10;
  for (int i = WRI - 1; i; i--) putchar((char)(Write[i] + 48));
}
void add(int x, int y) {
  e[++cnt] = (E){y, head[x]};
  head[x] = cnt;
}
void addedge(int x, int y) {
  add(x, y);
  add(y, x);
}
void del(int x) {
  b[x] = 1;
  r[l[x]] = r[x];
  l[r[x]] = l[x];
}
void bfs(int ljj) {
  queue<int> q;
  int sum = 1;
  q.push(ljj);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = head[u]; i; i = e[i].nxt) {
      int v = e[i].to;
      fa[v] = u;
    }
    for (int i = r[0]; i <= n; i = r[i])
      if (fa[i] != u && !b[i]) {
        q.push(i);
        del(i);
        sum++;
      }
  }
  ans[++ans_cnt] = sum;
}
int main() {
  n = read();
  m = read();
  for (int i = 1; i <= m; i++) addedge(read(), read());
  for (int i = 0; i <= n; i++) l[i] = i - 1, r[i] = i + 1;
  for (int i = 1; i <= n; i = r[i])
    if (!b[i]) {
      del(i);
      bfs(i);
    }
  sort(ans + 1, ans + 1 + ans_cnt);
  write(ans_cnt);
  puts("");
  for (int i = 1; i <= ans_cnt; i++) write(ans[i]), putchar(' ');
  return 0;
}
