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 8
7 9
7 10
7 11
7 12
8 9
8 10
8 11
9 10
9 11
9 12
10 12
 4 3
2 1
3 1
4 2
 3 1
2 3
 6 10
1 2
1 3
1 4
1 6
2 3
2 4
2 5
3 5
3 6
4 6
 11 49
10 3
6 4
11 3
7 6
10 6
6 1
4 3
10 2
4 5
9 2
10 1
5 7
1 5
9 7
2 11
8 6
3 9
2 5
9 5
6 5
1 4
11 9
1 7
8 10
3 6
3 7
11 5
6 9
4 10
8 7
4 9
8 2
4 2
8 11
7 4
9 10
8 1
10 7
3 2
5 8
8 9
1 3
2 7
10 11
5 3
10 5
4 11
1 11
8 3
 5 4
1 4
2 3
4 3
4 2
 4 3
1 2
3 1
4 3
 4 3
1 3
1 4
2 3
 10 36
7 8
7 9
2 3
2 4
2 5
9 10
2 7
2 8
2 9
2 10
4 5
4 6
4 7
4 8
4 10
6 7
6 9
6 10
1 2
1 3
1 4
8 9
1 5
8 10
1 7
1 8
1 9
1 10
3 4
3 6
3 7
3 9
5 6
5 7
5 9
5 10
 8 15
2 1
4 5
2 4
3 4
2 5
3 5
2 6
3 6
5 6
4 6
2 7
3 8
2 8
3 7
6 7

3
1 2 4 
 3
1 2 5 
 2
1 3 
 1
8 
 1
10 
 2
1 4 
 1
2 
 3
1 3 4 
 2
1 1 
 1
6 
 3
1 4 7 
 4
1 1 1 9 
 1
4 
 1
3 
 1
6 
 5
1 1 1 2 6 
 1
5 
 1
4 
 1
4 
 2
2 8 
 1
8 

import java.io.BufferedReader;
// import java.io.FileInputStream;
// import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.*;

import static java.lang.Math.*;
import static java.util.Arrays.copyOf;
import static java.util.Arrays.fill;
import static java.util.Arrays.sort;
import static java.util.Collections.reverseOrder;
import static java.util.Collections.sort;

public class Main {
    private FastScanner in;
    private PrintWriter out;

    private void solve() throws IOException {
        solveE();
    }

    private void solveA() throws IOException {
        int inf = 10000, n = in.nextInt(), k = in.nextInt();

        int[] x = new int[k + 2];
        x[0] = -inf;
        for (int i = 1; i <= k; i++)
            x[i] = in.nextInt();
        x[k + 1] = inf;

        int ans = -inf;
        for (int i = 1, j = 1; i <= n; i++) {
            ans = max(ans, min(i - x[j - 1], x[j] - i));
            if (x[j] == i)
                j++;
        }
        out.println(ans + 1);
    }

    private void solveB() throws IOException {
        int n = in.nextInt();
        int[] l = new int[n], r = new int[n];
        for (int i = 0; i < n; i++) {
            l[i] = in.nextInt();
            r[i] = in.nextInt();
        }

        int[] q = new int[n];
        for (int t = 1, i = 0, ql = 0, qr = 0; i < n || ql < qr; t++) {
            while (i < n && l[i] == t)
                q[qr++] = r[i++];

            while (ql < qr && q[ql] < t) {
                out.print(0 + " ");
                ql++;
            }
            if (ql < qr) {
                out.print(t + " ");
                ql++;
            }
        }
        out.println();
    }

    private void solveC() throws IOException {
        int n = in.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = in.nextInt() - 1;

        boolean[] b = new boolean[n];
        char[] c = in.next().toCharArray();
        for (int i = 0; i < c.length; i++)
            b[i] = c[i] == '1';

        boolean cnt[], ok = true;
        for (int l = 0, r; ok; l = r) {
            while (l < n && !b[l])
                l++;
            if (l == n)
                break;

            r = l;
            while (r < n && b[r])
                r++;
            if (r < n)
                r++;

            cnt = new boolean[r - l];
            for (int i = l; i < r; i++)
                if (a[i] < r && a[i] >= l)
                    cnt[a[i] - l] = true;

            for (boolean i : cnt)
                ok &= i;
        }

        for (int i = 0; i < n; i++)
            if (!b[i] && (i == 0 || !b[i - 1]))
                ok &= a[i] == i;

        out.println(ok ? "YES" : "NO");
    }

    private void solveD() throws IOException {
        int N = in.nextInt(), K = in.nextInt(), V = in.nextInt();

        int v = V % K, vk = V / K;

        int[] a = new int[N], k = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = in.nextInt();
            k[i] = a[i] / K;
            a[i] %= K;
        }


    }

    int[] color;
    int cnt, n;
    ArrayList<Integer>[] graph;

    private void solveE() throws IOException {
        n = in.nextInt();
        int m = in.nextInt();

        graph = new ArrayList[n];
        for (int i = 0; i < n; i++)
            graph[i] = new ArrayList<>();

        for (int i = 0, x, y; i < m; i++) {
            x = in.nextInt() - 1;
            y = in.nextInt() - 1;
            graph[x].add(y);
            graph[y].add(x);
        }

        for (int i = 0; i < n; i++)
            sort(graph[i]);

        color = new int[n];
        cnt = 0;
        for (int v = 0; v < n; v++)
            if (color[v] == 0) {
                cnt++;
                dfs(v);
            }

        int[] cnt = new int[this.cnt + 1];
        for (int i = 0; i < n; i++)
            cnt[color[i]]++;
        shuffle(cnt);
        sort(cnt);

        out.println(this.cnt);
        for (int i = 1; i <= this.cnt; i++) {
            out.print(cnt[i] + " ");
        }
    }

    private void dfs(int v) {
        color[v] = cnt;
        int p = -1;
        for (int u : graph[v]) {
            for (int i = p + 1; i < u; i++)
                if (color[u] == 0)
                    dfs(u);
            p = v;
        }
    }

    void shuffle(int[] a) {
        int b;
        Random r = new Random();
        for (int i = a.length - 1, j; i > 0; i--) {
            j = r.nextInt(i + 1);
            b = a[j];
            a[j] = a[i];
            a[i] = b;
        }
    }

    private void solveF() throws IOException {

    }

    class FastScanner {
        StringTokenizer st;
        BufferedReader br;

        FastScanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        boolean hasNext() throws IOException {
            return br.ready() || (st != null && st.hasMoreTokens());
        }

        int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        double nextDouble() throws IOException {
            return Double.parseDouble(next().replace(',', '.'));
        }

        String nextLine() throws IOException {
            return br.readLine();
        }

        boolean hasNextLine() throws IOException {
            return br.ready();
        }
    }

    private void run() throws IOException {
        in = new FastScanner(System.in); // new FastScanner(new FileInputStream(".in"));
        out = new PrintWriter(System.out); // new PrintWriter(new FileOutputStream(".out"));

        solve();

        out.flush();
        out.close();
    }

    public static void main(String[] args) throws IOException {
        new Main().run();
    }
}
