#include <bits/stdc++.h>
using namespace std;
void INPUT() {}
const int N = 200005;
set<int> s;
map<pair<int, int>, bool> h;
int tot, n, x, y, m;
void dfs(int node) {
  tot++;
  s.erase(node);
  set<int>::iterator it = s.begin();
  int id;
  while (it != s.end()) {
    id = *it;
    if (!h.count(make_pair(node, id))) {
      dfs(id);
      it = (s.begin());
    } else
      it++;
  }
}
void solve() {
  cin >> n >> m;
  h.clear();
  s.clear();
  while (m--) {
    cin >> x >> y;
    x--;
    y--;
    h[make_pair(x, y)] = 1;
    h[make_pair(y, x)] = 1;
  }
  for (int i = 0; i <= n - 1; i++) s.insert(i);
  vector<int> ans;
  int node;
  while (!s.empty()) {
    node = *(s.begin());
    tot = 0;
    dfs(node);
    ans.push_back(tot);
  }
  sort(ans.begin(), ans.end());
  cout << ans.size() << "\n";
  for (auto &i : ans) cout << i << " ";
  cout << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  INPUT();
  int t;
  t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
