#include <bits/stdc++.h>
using namespace std;
set<int> nvis;
set<pair<int, int> > ase;
int con[200005];
int cn;
int coun;
int sz[200005];
void dfs(int n) {
  nvis.erase(n);
  con[n] = coun;
  ++sz[coun];
  auto it = nvis.begin();
  int val = -1;
  while (it != nvis.end()) {
    int u = (*it);
    if (ase.find(make_pair(u, n)) != ase.end() ||
        ase.find(make_pair(n, u)) != ase.end()) {
      ++it;
    } else {
      val = u;
      dfs(u);
      it = nvis.lower_bound(u);
    }
  }
}
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    ase.insert(make_pair(a, b));
    ase.insert(make_pair(b, a));
  }
  for (int i = 1; i <= n; ++i) {
    nvis.insert(i);
  }
  for (int i = 1; i <= n; ++i) {
    if (nvis.find(i) != nvis.end()) {
      ++coun;
      dfs(i);
    }
  }
  cout << coun << endl;
  vector<int> ajak;
  for (int i = 1; i <= coun; ++i) {
    ajak.push_back(sz[i]);
  }
  sort(ajak.begin(), ajak.end());
  for (int i = 1; i <= coun; ++i) {
    printf("%d ", ajak[i - 1]);
  }
  cout << endl;
}
