#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
struct hash<pair<T, U>> {
  size_t operator()(const pair<T, U>& key) const {
    return (hash<T>()(key.first) ^ (hash<U>()(key.second) << 1)) << 1;
  }
};
struct cc_complement {
  int n;
  set<pair<int, int>>& edges;
  set<int> notvis;
  vector<vector<int>> cc;
  void bfs(int s) {
    queue<int> q;
    q.push(s);
    notvis.erase(s);
    while (q.size()) {
      int u = q.front();
      q.pop();
      cc.back().push_back(u);
      for (auto it = notvis.begin(); it != notvis.end();) {
        if (!edges.count({u, *it}) && !edges.count({*it, u})) {
          q.push(*it);
          it = notvis.erase(it);
        } else
          ++it;
      }
    }
  }
  cc_complement(int n_, set<pair<int, int>>& e) : n(n_), edges(e) {
    for (int v = 1; v <= n; ++v) {
      notvis.insert(v);
    }
    for (int v = 1; v <= n; ++v) {
      if (notvis.count(v)) {
        cc.emplace_back();
        bfs(v);
      }
    }
  }
};
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  set<pair<int, int>> edges;
  for (int i = 1; i <= m; ++i) {
    int u, v;
    cin >> u >> v;
    edges.insert({u, v});
  }
  vector<int> ans;
  cc_complement cc(n, edges);
  for (auto x : cc.cc) {
    ans.push_back(x.size());
  }
  sort(ans.begin(), ans.end());
  cout << ans.size() << '\n';
  for (int x : ans) {
    cout << x << ' ';
  }
  cout << '\n';
}
