#include <bits/stdc++.h>
using namespace std;
set<int> bag[200005 * 5];
int id[200005 * 5];
int P[200005 * 10];
int n, q;
vector<int> E[200005];
int MaxId = 0;
int Cnt[200005 * 10];
int f(int u) {
  if (P[u] != u) return P[u] = f(P[u]);
  return u;
}
void build(int p, int s, int e) {
  id[p] = p;
  MaxId = max(MaxId, p);
  if (s == e) return;
  int m = (s + e) / 2;
  build(p * 2 + 1, s, m);
  build(p * 2 + 2, m + 1, e);
}
void upd(int p, int s, int e, int l, int r, int i) {
  if (s > r || e < l) return;
  if (l <= s && e <= r) {
    bag[p].insert(i);
    return;
  }
  int m = (s + e) / 2;
  upd(p * 2 + 1, s, m, l, r, i);
  upd(p * 2 + 2, m + 1, e, l, r, i);
}
void addE(int u, int v) { P[f(u)] = f(v); }
void dnc(int p, int s, int e, int isi) {
  if (s == e) {
    for (auto it : bag[p]) {
      addE(s + MaxId, it + MaxId);
    }
    return;
  }
  int m = (s + e) / 2;
  dnc(p * 2 + 1, s, m, isi | (!bag[p].empty()));
  dnc(p * 2 + 2, m + 1, e, isi | (!bag[p].empty()));
  int isiisi = isi | (!bag[p].empty());
  if (isiisi) {
    for (int i = s; i < e; i++) addE(i + MaxId, i + MaxId + 1);
    for (auto it : bag[p]) {
      addE(it + MaxId, s + MaxId);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> q;
  for (int i = 0; i < q; i++) {
    int u, v;
    cin >> u >> v;
    if (u > v) swap(u, v);
    E[u].push_back(v);
  }
  build(0, 1, n);
  for (int i = 0; i <= MaxId + n; i++) P[i] = i;
  for (int i = 1; i <= n; i++) sort(E[i].begin(), E[i].end());
  for (int i = 1; i <= n; i++) {
    int last = i;
    int pos = lower_bound(E[i].begin(), E[i].end(), last) - E[i].begin();
    while (true) {
      if (pos == E[i].size()) break;
      int L = last + 1, R = E[i][pos];
      if (L < R) upd(0, 1, n, L, R - 1, i);
      last = R;
      pos++;
    }
    int L = last + 1, R = n;
    if (L <= R) {
      upd(0, 1, n, L, R, i);
    }
  }
  dnc(0, 1, n, 0);
  for (int i = MaxId + 1; i <= MaxId + n; i++) {
    Cnt[f(i)]++;
  }
  vector<int> son;
  for (int i = MaxId + 1; i <= MaxId + n; i++) {
    if (Cnt[f(i)] > 0) {
      son.push_back(Cnt[f(i)]);
      Cnt[f(i)] = 0;
    }
  }
  sort(son.begin(), son.end());
  cout << son.size() << endl;
  for (int i = 0; i < son.size(); i++) {
    if (i) cout << " ";
    cout << son[i];
  }
  cout << endl;
  return 0;
}
