#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200005;
int n, m;
int mark[MAXN];
int mark2[MAXN];
vector<int> mapp[MAXN];
vector<int> ans;
queue<int> qqq;
list<int> lli;
void bfs(int be) {
  int cnt = 1;
  qqq.push(be);
  mark[be] = 1;
  list<int>::iterator it;
  while (!qqq.empty()) {
    int tt = qqq.front();
    qqq.pop();
    for (auto u : mapp[tt]) mark2[u] = 1;
    for (it = lli.begin(); it != lli.end();) {
      if (!mark[*it] && !mark2[*it]) {
        qqq.push(*it);
        mark[*it] = 1;
        lli.erase(it++);
        cnt++;
      } else
        it++;
    }
    for (auto u : mapp[tt]) mark2[u] = 0;
  }
  ans.push_back(cnt);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ;
  cin >> n >> m;
  int u, v;
  for (int i = 1; i <= m; ++i) {
    cin >> u >> v;
    mapp[u].push_back(v);
    mapp[v].push_back(u);
  }
  for (int i = 1; i <= n; ++i) lli.push_back(i);
  for (int i = 1; i <= n; ++i) {
    if (mark[i]) continue;
    bfs(i);
  }
  cout << ans.size() << endl;
  sort(ans.begin(), ans.end());
  for (int i = 0; i < ans.size(); ++i) cout << ans[i] << " ";
  cout << endl;
  return 0;
}
