#include <bits/stdc++.h>
using namespace std;
int n, m, comp = 0, cnt[200100];
set<int> st;
set<int>::iterator it;
vector<int> v[200100];
vector<int> Answer;
map<pair<int, int>, int> mp;
bool vis[200100];
void DFS(int x) {
  vector<int> temp;
  vis[x] = true;
  cnt[comp]++;
  for (it = st.begin(); it != st.end(); it++) {
    if (!mp.count({x, *it}) && !vis[*it]) temp.push_back(*it);
  }
  for (int i = 0; i < temp.size(); i++) st.erase(temp[i]);
  for (int i = 0; i < temp.size(); i++) {
    DFS(temp[i]);
  }
}
int main() {
  int x, y;
  cin >> n >> m;
  while (m--) {
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
    mp[{x, y}]++;
    mp[{y, x}]++;
  }
  for (int i = 1; i <= n; i++) st.insert(i);
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) DFS(i), comp++;
  }
  for (int i = 0; i < n; i++) {
    if (cnt[i]) Answer.push_back(cnt[i]);
  }
  sort(Answer.begin(), Answer.end());
  cout << Answer.size() << endl;
  for (int i = 0; i < Answer.size(); i++) cout << Answer[i] << " ";
  return 0;
}
