#include <bits/stdc++.h>
using namespace std;
const int maxN = 2e5 + 7;
int n, m;
set<int> s[maxN], vis;
vector<int> ans, v;
queue<int> qu;
int BFS(int x) {
  qu.push(x);
  vis.erase(x);
  int cnt = 0;
  set<int>::iterator it;
  while (!qu.empty()) {
    v.clear();
    int u = qu.front();
    cnt++;
    qu.pop();
    for (it = vis.begin(); it != vis.end(); it++)
      if (s[u].find(*it) == s[u].end()) v.push_back(*it);
    for (int i = 0; i < v.size(); i++) {
      int p = v[i];
      qu.push(p);
      vis.erase(p);
    }
  }
  return cnt;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    s[u].insert(v);
    s[v].insert(u);
  }
  for (int i = 1; i <= n; i++) vis.insert(i);
  for (int i = 1; i <= n; i++) {
    if (vis.find(i) != vis.end()) ans.push_back(BFS(i));
  }
  cout << ans.size() << "\n";
  sort(ans.begin(), ans.end());
  for (int i = 0; i < ans.size(); i++) cout << ans[i] << " ";
  return 0;
}
