#include <bits/stdc++.h>
using namespace std;
const int MAX = 2e5 + 6;
set<int> unvisited;
set<int> g[MAX];
int sz;
void dfs(int u) {
  unvisited.erase(u);
  int cur = 0;
  sz++;
  while (1) {
    auto it = unvisited.upper_bound(cur);
    if (it == unvisited.end()) break;
    cur = *it;
    if (g[u].count(cur)) continue;
    dfs(cur);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    g[u].insert(v), g[v].insert(u);
  }
  for (int i = 1; i <= n; i++) unvisited.insert(i);
  vector<int> ans;
  for (int i = 1; i <= n; i++) {
    if (unvisited.count(i)) {
      dfs(i);
      ans.push_back(sz);
      sz = 0;
    }
  }
  sort(ans.begin(), ans.end());
  cout << ans.size() << "\n";
  for (int x : ans) cout << x << " ";
}
