#include <bits/stdc++.h>
using namespace std;
const int maxN = 2e5 + 7;
int N, M, head[maxN], cnt;
struct LIST {
  int pre, nex;
  LIST(int a = 0, int b = 0) : pre(a), nex(b) {}
} lst[maxN];
inline void Del(int id) {
  lst[lst[id].pre].nex = lst[id].nex;
  lst[lst[id].nex].pre = lst[id].pre;
  lst[id] = LIST();
}
struct Eddge {
  int nex, to;
  Eddge(int a = -1, int b = 0) : nex(a), to(b) {}
} edge[maxN << 1];
inline void addEddge(int u, int v) {
  edge[cnt] = Eddge(head[u], v);
  head[u] = cnt++;
}
inline void _add(int u, int v) {
  addEddge(u, v);
  addEddge(v, u);
}
bool vis[maxN] = {false};
int siz[maxN], KK = 0;
void bfs() {
  int it;
  while (lst[0].nex != N + 1) {
    siz[++KK] = 1;
    it = lst[0].nex;
    Del(it);
    queue<int> Q;
    Q.push(it);
    int u, now, nex;
    while (!Q.empty()) {
      u = Q.front();
      Q.pop();
      for (int i = head[u], v; ~i; i = edge[i].nex) {
        v = edge[i].to;
        vis[v] = true;
      }
      now = lst[0].nex;
      while (now != N + 1) {
        nex = lst[now].nex;
        if (vis[now])
          vis[now] = false;
        else {
          Del(now);
          Q.push(now);
          siz[KK]++;
        }
        now = nex;
      }
    }
  }
}
inline void init() {
  cnt = 0;
  for (int i = 1; i <= N; i++) {
    head[i] = -1;
    lst[i] = LIST(i - 1, i + 1);
  }
  lst[0].nex = 1;
  lst[N + 1].pre = N;
}
int main() {
  scanf("%d%d", &N, &M);
  init();
  for (int i = 1, u, v; i <= M; i++) {
    scanf("%d%d", &u, &v);
    _add(u, v);
  }
  bfs();
  printf("%d\n", KK);
  sort(siz + 1, siz + KK + 1);
  for (int i = 1; i <= KK; i++) printf("%d%c", siz[i], i == KK ? '\n' : ' ');
  return 0;
}
