#include <bits/stdc++.h>
using namespace std;
int n, m, x, y, cnt;
set<int> st1[200001], st2;
vector<int> ans;
void bfs(int s) {
  queue<int> q;
  q.push(s);
  if (st2.find(s) != st2.end()) st2.erase(s);
  while (!q.empty()) {
    int v = q.front();
    cnt++;
    q.pop();
    vector<int> aux;
    for (auto it : st2) {
      if (st1[v].find(it) == st1[v].end()) {
        q.push(it);
        aux.push_back(it);
      }
    }
    for (auto it : aux) st2.erase(it);
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    st1[x].insert(y);
    st1[y].insert(x);
  }
  for (int i = 1; i <= n; i++) st2.insert(i);
  for (int i = 1; i <= n; i++) {
    if (st2.find(i) != st2.end()) {
      cnt = 0;
      bfs(i);
      ans.push_back(cnt);
    }
  }
  sort(ans.begin(), ans.end());
  cout << ans.size() << "\n";
  for (auto it : ans) cout << it << " ";
  return 0;
}
