#include <bits/stdc++.h>
using namespace std;
const long long int N = 200010;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, m;
  cin >> n >> m;
  vector<long long int> adj[n + 1];
  for (long long int i = 0; i < m; ++i) {
    long long int a, b;
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  for (long long int i = 1; i <= n; ++i) {
    sort(adj[i].begin(), adj[i].end());
  }
  vector<long long int> ans;
  set<long long int> left;
  for (long long int i = 1; i <= n; ++i) {
    left.insert(i);
  }
  while (!left.empty()) {
    long long int v = *left.begin();
    left.erase(left.begin());
    long long int count = 0;
    queue<long long int> buffer;
    buffer.push(v);
    while (!buffer.empty()) {
      ++count;
      v = buffer.front();
      buffer.pop();
      set<long long int> newcandidates;
      for (auto u : adj[v]) {
        if (left.find(u) != left.end()) {
          newcandidates.insert(u);
          left.erase(u);
        }
      }
      for (auto u : left) {
        buffer.push(u);
      }
      left = newcandidates;
    }
    ans.push_back(count);
  }
  sort(ans.begin(), ans.end());
  cout << ans.size() << endl;
  for (long long int i = 0; i < ans.size(); ++i) {
    cout << ans[i] << " ";
  }
  return (0);
}
