#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  int n, m;
  cin >> n >> m;
  set<pair<int, int> > edges;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    edges.insert(make_pair(u, v));
    edges.insert(make_pair(v, u));
  }
  vector<int> pending;
  for (int i = 1; i <= n; i++) {
    pending.push_back(i);
  }
  vector<int> sizes;
  while (pending.size()) {
    int next = pending.back();
    pending.pop_back();
    int size = 1;
    queue<int> component;
    component.push(next);
    while (component.size()) {
      int u = component.front();
      component.pop();
      for (int i = 0; i < pending.size(); i++) {
        if (edges.count(make_pair(u, pending[i])) == 0) {
          size++;
          component.push(pending[i]);
          pending[i] = pending.back();
          pending.pop_back();
          i--;
        }
      }
    }
    sizes.push_back(size);
  }
  cout << sizes.size() << "\n";
  sort(sizes.begin(), sizes.end());
  for (auto v : sizes) {
    cout << v << " ";
  }
  cout << "\n";
  return 0;
}
