#include <bits/stdc++.h>
#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;
inline long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
inline long long power(long long a, long long n, long long m) {
  if (n == 0) return 1;
  long long p = power(a, n / 2, m);
  p = (p * p) % m;
  if (n % 2)
    return (p * a) % m;
  else
    return p;
}
const long long MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const long long LL_INF = 0x3f3f3f3f3f3f3f3f;
struct subset {
  int rank, parent;
};
int find(subset subsets[], int i) {
  if (subsets[i].parent == i) return i;
  subsets[i].parent = find(subsets, subsets[i].parent);
  return subsets[i].parent;
}
void Union(subset subsets[], int x, int y) {
  if (subsets[x].rank > subsets[y].rank)
    subsets[y].parent = x;
  else if (subsets[y].rank > subsets[x].rank)
    subsets[x].parent = y;
  else {
    subsets[y].parent = x;
    subsets[x].rank++;
  }
}
int cnt = 0;
set<int> unvisited;
void dfs(set<pair<int, int> >& s, int u) {
  unvisited.erase(u);
  set<int>::iterator it;
  cnt++;
  for (it = unvisited.begin(); it != unvisited.end();) {
    if (s.find(make_pair(u, *it)) == s.end()) {
      dfs(s, *it);
      it = unvisited.begin();
    } else
      it++;
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int n, m;
  cin >> n >> m;
  set<pair<int, int> > s;
  int u, v;
  for (int i = 0; i < m; i++) {
    cin >> u >> v;
    s.insert(make_pair(u, v));
    s.insert(make_pair(v, u));
  }
  for (int i = 1; i <= n; i++) unvisited.insert(i);
  vector<int> components;
  while (!unvisited.empty()) {
    cnt = 0;
    dfs(s, (*(unvisited.begin())));
    components.push_back(cnt);
  }
  cout << components.size() << endl;
  sort(components.begin(), components.end());
  for (int i = 0; i < components.size(); i++) cout << components[i] << " ";
  cout << endl;
  return 0;
}
