#include <bits/stdc++.h>
using namespace std;
int n, m, x, y, z, k, w, a, b;
long long t;
unordered_set<long long> edge;
long long f(int x, int y) { return 200001ll * min(x, y) + max(x, y); }
int p[200005], siz[200005], ans[200005];
int s, nxt[200005], pre[200005];
queue<int> Q;
void del(int x) {
  int a, b;
  a = pre[x];
  b = nxt[x];
  if (a == -1)
    pre[b] = -1, s = b;
  else {
    pre[b] = a;
    nxt[a] = b;
  }
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = (0); i < (m); i++) {
    scanf("%d %d", &x, &y);
    t = f(x, y);
    edge.insert(t);
  }
  for (int i = (1); i <= (n); i++) nxt[i] = i + 1, pre[i] = i - 1;
  ;
  nxt[n] = -1;
  pre[1] = -1;
  s = 1;
  for (int node = (1); node <= (n); node++) {
    if (p[node] > 0) continue;
    del(node);
    Q.push(node);
    while (!Q.empty()) {
      x = Q.front();
      p[x] = node;
      Q.pop();
      for (int i = s; i != -1; i = nxt[i]) {
        if (edge.find(f(x, i)) == edge.end()) {
          del(i);
          Q.push(i);
        }
      }
    }
  }
  w = 0;
  for (int i = (1); i <= (n); i++) siz[p[i]]++;
  for (int i = (1); i <= (n); i++)
    if (siz[i] > 0) ans[w++] = siz[i];
  sort(ans, ans + w);
  printf("%d\n", w);
  for (int i = (0); i < (w); i++) printf("%d ", ans[i]);
  return 0;
}
