#include <bits/stdc++.h>
using namespace std;
long long int powmod(long long int base, long long int pow) {
  long long int res = 1;
  while (pow) {
    if (pow % 2 != 0) res = (res * base) % 1000000007;
    base = (base * base) % 1000000007;
    pow /= 2;
  }
  return res;
}
set<int> v;
set<int> g[200005];
int dfs(int ver) {
  int sum = 1;
  for (set<int>::iterator it = v.begin(); it != v.end();) {
    int vv = *it;
    if (g[ver].find(vv) != g[ver].end())
      it++;
    else {
      v.erase(vv);
      sum += dfs(vv);
      it = v.lower_bound(vv);
    }
  }
  return sum;
}
vector<long long int> sizess;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  for (long long int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    g[x].insert(y);
    g[y].insert(x);
  }
  for (long long int i = 0; i < n; i++) v.insert(i);
  while (v.size()) {
    int x = *(v.begin());
    v.erase(x);
    sizess.push_back(dfs(x));
  }
  cout << sizess.size() << "\n";
  sort(sizess.begin(), sizess.end());
  for (long long int i = 0; i < sizess.size(); i++) cout << sizess[i] << " ";
}
