#include <bits/stdc++.h>
using namespace std;
const int INF = int(1e9);
int dx[] = {2, 2, -2, -2, 1, 1, -1, -1};
int dy[] = {-1, 1, 1, -1, 2, -2, 2, -2};
int dxx[] = {1, 0, 0, -1};
int dyy[] = {0, 1, -1, 0};
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
void add(int &a, int b) {
  a += b;
  if (a >= 1000000007) a -= 1000000007;
}
int poww(int x, int y) {
  if (y == 0) return 1;
  if (y == 1) return x;
  return x * poww(x, y - 1);
}
long long int strtoint(string s) {
  int l = s.length();
  long long int temp = 0;
  for (int i = 0; i < l; i++) {
    if (i != l - 1)
      temp = temp + (s[i] - '0') * poww(10, l - i - 1);
    else
      temp = temp + (s[i] - '0');
  }
  return temp;
}
int isprime(long long int x) {
  if (x == 1) return 1;
  if (x == 2) return 1;
  if (x == 3) return 1;
  for (int i = 2; i * i <= x; i++)
    if (x % i == 0) return 0;
  return 1;
}
void cpgod() {}
int lexbig(string s1, string s2) {
  int n1, n2;
  n1 = s1.length();
  n2 = s2.length();
  for (int i = 0; i < n1; i++) {
    if (s1[i] - 'a' > s2[i] - 'a')
      return 1;
    else if (s1[i] - 'a' < s2[i] - 'a')
      return 0;
    else
      continue;
  }
  if (n1 == n2)
    return 1;
  else
    return 0;
}
long long int fast_pow(long long int a, long long int p) {
  long long int res = 1;
  while (p) {
    if (p % 2 == 0) {
      a = a * 1ll * a % 1000000007;
      p /= 2;
    } else {
      res = res * 1ll * a % 1000000007;
      p--;
    }
  }
  return res;
}
long long int lcm(long long int x, long long int y) {
  long long int t = x * y;
  t = t / (gcd(x, y));
  return t;
}
long long int modadd(long long int a, long long int b) {
  a = a % 1000000007;
  b = b % 1000000007;
  return (a + b) % 1000000007;
}
int binaryToDecimal(string n) {
  string num = n;
  int dec_value = 0;
  int base = 1;
  int len = num.length();
  for (int i = len - 1; i >= 0; i--) {
    if (num[i] == '1') dec_value += base;
    base = base * 2;
  }
  return dec_value;
}
long long int ncr(long long int x, long long int y) {
  long long int mul = 1;
  for (int i = x; i > x - y; i--)
    mul = (mul % 1000000007 * i % 1000000007) % 1000000007;
  long long int rem = 1;
  for (int i = 2; i <= y; i++)
    rem = (rem % 1000000007 * i % 1000000007) % 1000000007;
  rem = fast_pow(rem, 1000000007 - 2);
  return (mul % 1000000007 * rem % 1000000007) % 1000000007;
}
vector<set<long long int>> adj(200020);
set<long long int> notused;
int con[200020];
int temp = 0;
vector<int> vaa;
void dfs(int src) {
  temp++;
  notused.erase(src);
  int cur = -1;
  int sear = -1;
  while (1) {
    auto ta = notused.upper_bound(sear);
    if (ta == notused.end()) break;
    sear = *ta;
    if (adj[src].find(sear) == adj[src].end()) {
      con[sear] = con[src];
      dfs(sear);
    } else {
      continue;
    }
  }
}
int main() {
  cpgod();
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) notused.insert(i);
  long long int a, b;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    adj[a].insert(b);
    adj[b].insert(a);
  }
  int sum = 0;
  while (notused.size() != 0) {
    int ta = *(notused.begin());
    temp = 0;
    dfs(ta);
    vaa.push_back(temp);
    sum++;
  }
  cout << sum << endl;
  sort(vaa.begin(), vaa.end());
  for (auto u : vaa) cout << u << endl;
  return 0;
}
