#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
list<int> vec;
list<int>::iterator it;
vector<int> a[N];
queue<int> q;
bool flag[N];
bool f[N];
int ans[N];
int n, m;
void bfs(int x, int e) {
  while (!q.empty()) q.pop();
  q.push(x);
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    if (flag[v]) continue;
    flag[v] = 1;
    ans[e]++;
    int len = a[v].size();
    for (int i = 0; i < len; i++) f[a[v][i]] = 1;
    for (it = vec.begin(); it != vec.end();) {
      int u = (*it);
      if (!f[u]) {
        q.push(u);
        vec.erase(it++);
      } else
        it++;
    }
    for (int i = 0; i < len; i++) f[a[v][i]] = 0;
  }
  return;
}
int main() {
  ios::sync_with_stdio(false);
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) vec.push_back(i);
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    a[x].push_back(y);
    a[y].push_back(x);
  }
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (!flag[i]) {
      cnt++;
      bfs(i, cnt);
    }
  }
  printf("%d\n", cnt);
  sort(ans + 1, ans + cnt + 1);
  for (int i = 1; i < cnt; i++) {
    printf("%d ", ans[i]);
  }
  printf("%d\n", ans[cnt]);
  return 0;
}
