#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 111;
set<int> g[N], fr;
int n, m, i1, i2, cnt;
vector<int> ans;
void dfs(int v) {
  fr.erase(v);
  cnt++;
  int cur = -1;
  while (!fr.empty()) {
    auto it = fr.upper_bound(cur);
    if (it == fr.end()) break;
    int to = *it;
    cur = to;
    if (g[v].find(to) == g[v].end()) dfs(to);
  }
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &i1, &i2);
    i1--;
    i2--;
    g[i1].insert(i2);
    g[i2].insert(i1);
  }
  for (int i = 0; i < n; i++) fr.insert(i);
  for (int i = 0; i < n; i++)
    if (fr.find(i) != fr.end()) {
      cnt = 0;
      dfs(i);
      ans.push_back(cnt);
    }
  sort(ans.begin(), ans.end());
  printf("%d\n", (int)ans.size());
  for (int i = 0; i < (int)ans.size(); i++) printf("%d ", ans[i]);
  return 0;
}
