#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
set<int> rem;
struct dsu {
  vector<int> p, sz;
  int comp;
  void init(int NN) {
    sz.clear();
    p.clear();
    p.resize(NN);
    sz.resize(NN, 1);
    iota(p.begin(), p.end(), 0);
    comp = NN;
  }
  int get(int x) { return (x == p[x] ? x : (p[x] = get(p[x]))); }
  void unite(int x, int y) {
    x = get(x);
    y = get(y);
    if (x != y) {
      p[x] = y;
      sz[y] += sz[x];
      sz[x] = 0;
      comp--;
    }
  }
} g;
int n;
set<int> mp[N];
void dfs(int cur) {
  rem.erase(cur);
  vector<int> v;
  for (auto i : rem) {
    if (mp[cur].find(i) == mp[cur].end()) {
      v.push_back(i);
      g.unite(cur, i);
    }
  }
  for (auto ele : v) {
    rem.erase(ele);
  }
  for (auto ele : v) {
    dfs(ele);
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  {
    int i, j, k, m, ans = 0, cnt = 0, sum = 0;
    cin >> n >> m;
    for (i = 1; i <= n; i++) {
      rem.insert(i);
    }
    int l, r;
    for (i = 0; i < m; i++) {
      cin >> l >> r;
      mp[l].insert(r);
      mp[r].insert(l);
    }
    g.init(n + 1);
    for (i = 1; i <= n; i++) {
      if (rem.find(i) != rem.end()) dfs(i);
    }
    vector<int> v;
    map<int, bool> mpp;
    for (i = 1; i <= n; i++) {
      if (mpp[g.get(i)] == 0) {
        mpp[g.get(i)] = 1;
        v.push_back(g.sz[g.get(i)]);
      }
    }
    sort(v.begin(), v.end());
    cout << v.size() << "\n";
    for (auto ele : v) {
      cout << ele << " ";
    }
  }
  return 0;
}
