#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T &x) {
  char c;
  bool nega = 0;
  while ((!isdigit(c = getchar())) && (c != '-'))
    ;
  if (c == '-') {
    nega = 1;
    c = getchar();
  }
  x = c - 48;
  while (isdigit(c = getchar())) x = x * 10 + c - 48;
  if (nega) x = -x;
}
template <typename T>
inline void writep(T x) {
  if (x > 9) writep(x / 10);
  putchar(x % 10 + 48);
}
template <typename T>
inline void write(T x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  writep(x);
}
template <typename T>
inline void writeln(T x) {
  write(x);
  putchar('\n');
}
vector<int> g[200001];
vector<int> h[200001];
bool done[200001];
int n, m;
int r[200001];
int root(int u) {
  if (r[u] < 0) return u;
  return r[u] = root(r[u]);
}
void uni(int u, int v) {
  u = root(u);
  v = root(v);
  if (u == v) return;
  h[u].push_back(v);
  h[v].push_back(u);
  r[u] += r[v];
  r[v] = u;
}
vector<int> good;
vector<int> boss;
set<int> s;
int dfstime[200001];
vector<int> ans;
int ntime;
bool dfs(int u, int a) {
  if (s.find(u) == s.end()) {
    uni(u, a);
    return 1;
  }
  dfstime[u] = ntime;
  for (int v : h[u])
    if (dfstime[v] != ntime)
      if (dfs(v, a)) return 1;
  return 0;
}
int main() {
  read(n);
  read(m);
  for (int i = (1); i <= (n); i++) {
    r[i] = -1;
    good.push_back(i);
  }
  {
    int u, v;
    for (int i = (1); i <= (m); i++) {
      read(u);
      read(v);
      g[u].push_back(v);
      g[v].push_back(u);
    }
  }
  sort(good.begin(), good.end(),
       [](int a, int b) { return (g[a].size()) < (g[b].size()); });
  boss.push_back(good[0]);
  done[good[0]] = 1;
  for (int v : g[boss.back()]) s.insert(v);
  for (int i = (1); i <= (n); i++)
    if (s.find(i) == s.end()) {
      uni(boss.back(), i);
      done[i] = 1;
    }
  for (int u : good) {
    if (done[u]) continue;
    s.clear();
    for (int v : g[u]) s.insert(v);
    for (int v : boss) {
      int a = root(v);
      if ((-r[a]) > ((int)g[u].size())) {
        uni(u, v);
        done[u] = 1;
      } else {
        ntime++;
        if (dfs(v, u)) done[u] = 1;
      }
    }
    if (!done[u]) {
      boss.push_back(u);
      for (int i = (1); i <= (n); i++)
        if (s.find(i) == s.end()) {
          uni(boss.back(), i);
        }
    }
  }
  s.clear();
  for (int i : boss)
    if (s.find(root(i)) == s.end()) {
      s.insert(root(i));
      ans.push_back(-r[root(i)]);
    }
  sort(ans.begin(), ans.end());
  writeln(ans.size());
  for (int x : ans) write(x), putchar(' ');
}
