#include <bits/stdc++.h>
using namespace std;
const int INF = ~(1 << 31);
const int NINF = 1 << 31;
const int N = 2e5 + 5;
int res[N];
int n, m, cnt;
set<int> e[N];
set<int> s;
void dfs(int first) {
  int second;
  s.erase(first), res[cnt]++;
  for (auto it = s.begin(); it != s.end(); it = s.upper_bound(second)) {
    second = *it;
    if (!e[first].count(*it)) dfs(second);
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int T;
  while (cin >> n >> m) {
    s.clear();
    for (int i = (1); i <= (n); ++i) s.insert(i);
    for (int i = (1); i <= (m); ++i) {
      int first, second;
      cin >> first >> second;
      e[first].insert(second), e[second].insert(first);
    }
    cnt = 0;
    for (int i = (1); i <= (n); ++i) {
      if (s.count(i)) {
        dfs(i), ++cnt;
      }
    }
    sort(res, res + cnt);
    cout << cnt << '\n';
    for (int i = (0); i <= (cnt - 1); ++i) {
      cout << res[i];
      if (i == cnt - 1)
        cout << '\n';
      else
        cout << ' ';
    }
  }
  return 0;
}
