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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 javafx.scene.layout.Priority;

import java.sql.Array;
import java.util.*;
import java.io.*;
import java.util.stream.Stream;

import static java.lang.Math.*;
public class D
{
    static InputReader in=new InputReader(System.in);
    static OutputWriter out=new OutputWriter(System.out);
    static StringBuilder sb=new StringBuilder();
    static long MOD = (long)(998244353);

    static HashSet<Integer>[] graph;
    static TreeSet<Integer> vertices;
    static boolean visited[];
    static int n;
    static int m;
    static int size;

    public static void dfs(int i){
        if(visited[i]) return;
        size++;
        visited[i] = true;
        vertices.remove(i);
        for(int j = i + 1 ;j < n; j++){
            if(graph[i].contains(j)){
                continue;
            }
            dfs(j);
        }
        return;
    }


    // Main Class Starts Here
    public static void main(String args[])throws IOException
    {
        // Write your code.
        int t = 1;
        while(t-->0) {
            n = in();
            m = in();

            graph = new HashSet[n];
            for(int i = 0; i < n; i++){
                graph[i] = new HashSet<Integer>();
            }

            vertices = new TreeSet<Integer>();
            for(int i = 0 ;i < n; i++) vertices.add(i);

            for(int i = 1; i <= m; i++){
                int u = in();
                int v = in();
                u--;
                v--;
                graph[u].add(v);
                graph[v].add(u);
            }

            visited = new boolean[n];

            int zcc = 0; // zero connected components

            Vector<Integer> cc = new Vector<>();
            for(int ver = 0 ; ver < n ; ver++){
                if(!visited[ver]){
                    size = 0;
                    zcc++;
                    dfs(ver);
                    cc.add(size);
                }
            }
            Collections.sort(cc);

            app(zcc+"\n");
            for(int x: cc)app(x+" ");

        }
        out.printLine(sb);
        out.close();
    }

    static class DisjointSet{
        int par[];
        int rank[];
        int n;
        public DisjointSet(int n){
            this.n = n;
            par = new int[n];
            rank = new int[n];
            for(int i = 0; i < n; i++){
                par[i] = i;
            }
        }

        public int findPar(int i){
            // path compression.
            if(par[i] != i){
                par[i] = findPar(par[i]);
            }
            return par[i];
        }

        public int merge(int x, int y){
            int parX = findPar(x);
            int parY = findPar(y);
            if(parX == parY) return 0; // no decrease in connected components
            if(rank[parX] > rank[parY]){
                // merge y to x.
                par[parY] = parX;
            }
            else if(rank[parY] > rank[parX]){
                par[parX] = parY;
            }
            else{
                par[parY] = parX;
                rank[parX]++;
            }
            return 1; // after merging the decrease in connected components is 1.
        }
    }

    public static class Edge{
        int from;
        int to;
        int id;
        boolean visited;
        public Edge(int from, int to, int id){
            this.from = from;
            this.to = to;
            this.id =id;
            this.visited = false;
        }
    }

    public static int[] an(int n) {
        int ar[]=new int[n];
        for(int i=0;i<n;i++)
            ar[i]=in();
        return ar;
    }

    public static long[] lan(int n) {
        long ar[]=new long[n];
        for(int i=0;i<n;i++)
            ar[i]=lin();
        return ar;
    }

    public static String atos(Object ar[]) {
        return Arrays.toString(ar);
    }

    public static int in() {
        return in.readInt();
    }

    public static long lin() {
        return in.readLong();
    }

    public static String sn() {
        return in.readString();
    }

    public static void prln(Object o) {
        out.printLine(o);
    }

    public static void prn(Object o) {
        out.print(o);
    }

    public static void display(int a[]) {
        out.printLine(Arrays.toString(a));
    }

    public static HashMap<Integer,Integer> hm(int a[]){
        HashMap<Integer,Integer> map=new HashMap<>();
        for(int i=0; i < a.length;i++) {
            int keep = (int)map.getOrDefault(a[i],0);
            map.put(a[i],++keep);
        }
        return map;
    }

    public static void app(Object o) {
        sb.append(o);
    }

    public static long calcManhattanDist(int x1,int y1,int x2,int y2) {
        long xa = Math.abs(x1-x2);
        long ya = Math.abs(y1-y2);
        return (xa+ya);
    }


    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public long readLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public String readString() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next() {
            return readString();
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object...objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0)
                    writer.print(' ');
                writer.print(objects[i]);
            }
        }

        public void printLine(Object...objects) {
            print(objects);
            writer.println();
        }

        public void close() {
            writer.close();
        }
    }
}