#include <bits/stdc++.h>
using namespace std;
struct $ {
  $() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout << fixed << setprecision(9);
  }
} $;
const int N = 200001;
bool vis[N];
set<int> adj[N];
set<int> gadj;
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    adj[u].insert(v);
    adj[v].insert(u);
  }
  multiset<int> sizes;
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      for (int i = 1; i <= n; i++) gadj.insert(i);
      int size = 0;
      vis[i] = true;
      deque<int> Q = {i};
      while (!Q.empty()) {
        size++;
        int u = Q.front();
        Q.pop_front();
        vector<int> ne;
        for (int v : gadj) {
          if (!adj[u].count(v)) {
            if (!vis[v]) {
              ne.push_back(v);
            }
          }
        }
        for (int v : ne) {
          vis[v] = true;
          gadj.erase(v);
          Q.push_back(v);
        }
      }
      sizes.insert(size);
    }
  }
  cout << sizes.size() << endl;
  int sum = 0;
  for (int u : sizes) {
    cout << u << " ";
    sum += u;
  }
  assert(sum == n);
  cout << endl;
  return 0;
}
