#include <bits/stdc++.h>
using namespace std;
struct UnionFind {
  vector<int> dat;
  UnionFind(int n) : dat(n, -1) {}
  int find(int x) {
    if (dat[x] < 0) return x;
    return dat[x] = find(dat[x]);
  }
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    dat[x] += dat[y];
    dat[y] = x;
  }
  int size(int x) { return -dat[find(x)]; }
  vector<int> iter_roots() {
    vector<int> res;
    for (int i = 0; i < dat.size(); i++) {
      if (dat[i] < 0) {
        res.push_back(i);
      }
    }
    return res;
  }
};
UnionFind complement_connected_components(vector<vector<int>> g) {
  const int n = g.size();
  queue<int> q;
  vector<int> yet;
  vector<bool> vis(n);
  for (int i = 0; i < n; i++) {
    yet.push_back(i);
    sort(g[i].begin(), g[i].end());
  }
  UnionFind uf(n);
  for (int i = 0; i < n; i++) {
    if (vis[i]) continue;
    q.push(i);
    while (!q.empty()) {
      int u = q.front();
      q.pop();
      vis[u] = true;
      vector<int> nxt;
      for (int v : yet) {
        if (binary_search(g[u].begin(), g[u].end(), v)) {
          nxt.push_back(v);
        } else {
          uf.unite(u, v);
          q.push(v);
        }
      }
      yet = move(nxt);
    }
  }
  return uf;
}
vector<vector<int>> read_graph(int n, int m) {
  vector<vector<int>> g(n);
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    u--;
    v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  return g;
}
template <class X, class Y>
vector<Y> fmap(function<Y(X)> f, vector<X> xs) {
  for (auto &x : xs) {
    x = f(x);
  }
  return xs;
}
void print(vector<int> a) {
  for (size_t i = 0; i < a.size(); i++) {
    if (i != 0) printf(" ");
    printf("%d", a[i]);
  }
  printf("\n");
}
template <class T>
vector<T> sort(vector<T> xs) {
  sort(xs.begin(), xs.end());
  return xs;
}
int main() {
  int n, m;
  cin >> n >> m;
  auto uf = complement_connected_components(read_graph(n, m));
  auto ans = uf.iter_roots();
  ans = fmap<int, int>([&](int x) { return uf.size(x); }, ans);
  ans = sort(ans);
  cout << ans.size() << endl;
  print(ans);
}
