#include <bits/stdc++.h>
using namespace std;
template <class TH>
void _dbg(const char *sdbg, TH h) {
  cerr << sdbg << "=" << h << "\n";
}
template <class TH, class... TA>
void _dbg(const char *sdbg, TH h, TA... a) {
  while (*sdbg != ',') cerr << *sdbg++;
  cerr << "=" << h << ",";
  _dbg(sdbg + 1, a...);
}
const int N = 5 * 100 * 1000 + 7;
int test;
int n, m;
map<pair<int, int>, int> e;
int par[N], rnk[N];
int t[N];
vector<int> G;
set<int> s;
vector<int> g[N];
vector<int> dow;
int fnd(int a) {
  if (par[a] != a) {
    par[a] = fnd(par[a]);
  }
  return par[a];
}
void uni(int a, int b) {
  a = fnd(a);
  b = fnd(b);
  if (a != b) {
    if (rnk[a] > rnk[b]) {
      par[b] = a;
      rnk[a] += rnk[b];
      for (auto it : g[b]) {
        g[a].push_back(it);
      }
      dow.push_back(b);
    } else {
      par[a] = b;
      rnk[b] += rnk[a];
      for (auto it : g[a]) {
        g[b].push_back(it);
      }
      dow.push_back(a);
    }
  }
}
void solve() {
  cin >> n >> m;
  for (int i = 1; i <= (m); ++i) {
    int a, b;
    cin >> a >> b;
    e[make_pair(a, b)] = e[make_pair(b, a)] = 1;
  }
  for (int i = 1; i <= (n); ++i) {
    par[i] = i;
    rnk[i] = 1;
    s.insert(i);
    g[i].push_back(i);
  }
  for (int i = 1; i <= (n); ++i) {
    dow.clear();
    for (auto it : s) {
      if (it != i)
        for (auto it1 : g[it]) {
          if (e[make_pair(i, it1)] == 0) {
            uni(i, it1);
            break;
          }
        }
    }
    for (auto it : dow) {
      s.erase(it);
    }
  }
  for (int i = 1; i <= (n); ++i) {
    t[fnd(i)]++;
  }
  for (int i = 1; i <= (n); ++i) {
    if (t[i]) {
      G.push_back(t[i]);
    }
  }
  sort(G.begin(), G.end());
  cout << G.size() << '\n';
  for (auto it : G) {
    cout << it << " ";
  }
  return;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.precision(10);
  cout << fixed;
  test = 1;
  while (test--) {
    solve();
  }
  return 0;
}
