#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return f * x;
}
inline void chmax(int &x, int y) { x = max(x, y); }
inline void chmin(int &x, int y) { x = min(x, y); }
inline void pls(int &x, int y, int Mod) {
  x = (x + y >= Mod) ? (x + y - Mod) : (x + y);
}
inline void red(int &x, int y, int Mod) {
  x = (x - y < 0) ? (x - y + Mod) : (x - y);
}
const int MAXN = 200005;
int n, m;
vector<int> G[MAXN];
int fa[MAXN];
inline int find(int x) {
  if (fa[x] == x) return x;
  return fa[x] = find(fa[x]);
}
pair<int, int> lk[MAXN];
inline void del(int x) {
  lk[lk[x].first].second = lk[x].second;
  lk[lk[x].second].first = lk[x].first;
}
bool vis1[MAXN], vis2[MAXN];
int cnt[MAXN];
signed main() {
  n = read(), m = read();
  for (int i = 1; i <= m; i++) {
    int x = read(), y = read();
    G[x].push_back(y);
    G[y].push_back(x);
  }
  for (int i = 1; i <= n; i++) {
    fa[i] = i;
    lk[i - 1].second = i;
    lk[i].first = i - 1;
  }
  queue<int> q;
  while (lk[0].second) {
    int now = lk[0].second;
    del(now);
    q.push(now);
    while (!q.empty()) {
      int p = q.front();
      q.pop();
      vis1[p] = true;
      for (int i : G[p])
        if (!vis1[i]) vis2[i] = true;
      int cur = lk[0].second;
      while (cur) {
        if (!vis2[cur]) {
          fa[find(cur)] = find(p);
          del(cur);
          q.push(cur);
        }
        cur = lk[cur].second;
      }
      for (int i : G[p]) vis2[i] = false;
    }
  }
  vector<int> ans;
  memset(vis1, false, sizeof(vis1));
  for (int i = 1; i <= n; i++) cnt[find(i)]++;
  for (int i = 1; i <= n; i++)
    if (cnt[i]) ans.push_back(cnt[i]);
  sort(ans.begin(), ans.end());
  cout << (int)ans.size() << endl;
  for (int i : ans) cout << i << ' ';
  return 0;
}
