#include <bits/stdc++.h>
using namespace std;
const int maxn = 200010;
int n, m;
int l[maxn];
int r[maxn];
vector<int> G[maxn];
int res[maxn], tmp;
void bfs(int s) {
  queue<int> Q;
  Q.push(s);
  r[l[s]] = r[s];
  l[r[s]] = l[s];
  tmp++;
  while (!Q.empty()) {
    int u = Q.front();
    Q.pop();
    int sz = G[u].size();
    for (int i = r[0], j = 0; i != n + 1; i = r[i]) {
      while (j < sz && G[u][j] < i) j++;
      if (j < sz && G[u][j] == i)
        j++;
      else {
        Q.push(i);
        tmp++;
        r[l[i]] = r[i];
        l[r[i]] = l[i];
      }
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i <= n; i++) l[i] = i - 1, r[i] = i + 1;
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    G[u].push_back(v);
    G[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) sort(G[i].begin(), G[i].end());
  res[0] = 0;
  while (r[0] != n + 1) {
    tmp = 0;
    bfs(r[0]);
    res[++res[0]] = tmp;
  }
  sort(res + 1, res + res[0] + 1);
  printf("%d\n", res[0]);
  for (int i = 1; i <= res[0]; i++) {
    if (i != 1) printf(" ");
    printf("%d", res[i]);
  }
  printf("\n");
  return 0;
}
