#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
long long bp(long long a, long long n) {
  if (n == 0) return 1;
  if (n & 1) return (a * bp(a, n - 1));
  long long ans = bp(a, (n >> 1));
  return (ans * ans);
}
const int N = 2e5 + 123, inf = 1e9 + 123;
int n, m;
set<int> st, g[N];
vector<int> comp;
const long long INF = 1e18 + 123;
void Dfs(int v) {
  st.erase(v);
  comp.push_back(v);
  int to = -1;
  while (st.upper_bound(to) != st.end()) {
    to = *st.upper_bound(to);
    if (g[v].find(to) == g[v].end()) {
      Dfs(to);
    }
  }
}
int main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(NULL);
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    g[x].insert(y);
    g[y].insert(x);
  }
  for (int i = 1; i <= n; i++) {
    st.insert(i);
  }
  vector<int> ans;
  for (int i = 1; i <= n; i++) {
    if (st.find(i) != st.end()) {
      comp.clear();
      Dfs(i);
      ans.push_back(comp.size());
    }
  }
  sort(ans.begin(), ans.end());
  cout << ans.size() << '\n';
  for (auto it : ans) {
    cout << it << ' ';
  }
  return 0;
}
