2 0
 100000 0
 8 9
1 2
2 3
3 4
4 1
5 6
6 7
7 8
8 5
6 8
 2 1
1 2
 11 9
5 9
8 5
11 3
11 1
3 4
7 11
3 1
11 2
7 2
 7 9
7 3
7 4
1 2
2 3
3 1
3 4
4 5
5 6
6 4
 7 5
5 4
7 3
7 1
6 7
3 1
 7 8
1 2
2 3
3 4
4 1
3 5
5 6
6 7
7 3
 6 9
1 2
2 3
1 4
4 2
5 2
5 3
4 5
6 4
6 5
 7 9
1 2
2 4
4 3
3 1
2 3
4 5
5 6
6 7
7 4
 1 0
 6 7
1 2
2 3
3 1
3 4
4 5
5 6
6 4
 4 5
1 2
2 3
3 4
4 1
1 3
 100000 3
99998 99999
99999 100000
100000 99998

0

 0

 4
1 2 3 4 
 0

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

 4
6 7 8 9 
 0

 6
1 2 3 5 6 7 
 0

 3
1 2 3 

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.util.Arrays;
import java.util.Iterator;
import java.io.IOException;
import java.io.Writer;
import java.util.NoSuchElementException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author palayutm
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskF solver = new TaskF();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskF {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.nextInt(), m = in.nextInt();
            Graph g = new Graph(n);
            int[] U = new int[m];
            int[] V = new int[m];
            for (int i = 0; i < m; i++) {
                U[i] = in.nextInt() - 1;
                V[i] = in.nextInt() - 1;
                g.addEdge(U[i], V[i]);
                g.addEdge(V[i], U[i]);
            }
            BiconnectedComponent bc = new UndirectedTarjan(g);
            int[] sum = new int[bc.getComponentsNumber()];
            IntArrayList[] ret = new IntArrayList[bc.getComponentsNumber()];
            for (int i = 0; i < ret.length; i++) {
                ret[i] = new IntArrayList();
            }
            for (int i = 0; i < m; i++) {
                if (bc.getComponentID(U[i]) == bc.getComponentID(V[i])) {
                    ret[bc.getComponentID(U[i])].add(i + 1);
                }
            }
            IntArrayList ans = new IntArrayList();
            int[][] components = bc.getComponents();
            for (int i = 0; i < ret.length; i++) {
                if (ret[i].size() == components[i].length) {
                    for (int j = 0; j < ret[i].size(); j++) {
                        ans.add(ret[i].get(j));
                    }
                }
            }
            out.println(ans.size());
            int[] b = ans.toArray();
            Arrays.sort(b);
            out.println(b);
        }

    }

    static class MyArrayList<T> implements Iterable<T> {
        private static final int DEFAULT_CAPACITY = 10;
        private static final double ENLARGE_SCALE = 2.0;
        Object[] array;
        int size;

        public MyArrayList() {
            this(DEFAULT_CAPACITY);
        }

        public MyArrayList(int capacity) {
            array = new Object[capacity];
            size = 0;
        }

        public void add(T value) {
            if (size == array.length) {
                enLarge();
            }
            array[size++] = value;
        }

        private void enLarge() {
            Object[] newArray = new Object[(int) (array.length * ENLARGE_SCALE)];
            System.arraycopy(array, 0, newArray, 0, size);
            array = newArray;
        }


        public Iterator<T> iterator() {
            return new Iterator<T>() {
                private int currentIndex = 0;


                public boolean hasNext() {
                    return currentIndex < size;
                }


                public T next() {
                    return (T) array[currentIndex++];
                }


                public void remove() {
                    throw new UnsupportedOperationException();
                }
            };
        }

    }

    static class OutputWriter extends PrintWriter {
        public OutputWriter(OutputStream out) {
            super(out);
        }

        public OutputWriter(Writer out) {
            super(out);
        }

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

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

        public void println(int[] a) {
            print(a);
            println();
        }

    }

    static interface BiconnectedComponent {
        int getComponentID(int vertexID);

        int getComponentsNumber();

        int[][] getComponents();

    }

    static class IntArrayList {
        private static final int DEFAULT_CAPACITY = 10;
        int[] array;
        int size;

        public IntArrayList() {
            this(DEFAULT_CAPACITY);
        }

        public IntArrayList(int capacity) {
            array = new int[capacity];
            size = 0;
        }

        public IntArrayList(int size, int initialValue) {
            String s;
            array = new int[size];
            Arrays.fill(array, initialValue);
            this.size = size;
        }

        public IntArrayList(int[] src) {
            array = Arrays.copyOf(src, src.length);
            size = array.length;
        }

        public int get(int index) {
            if (index < 0 || index >= size) {
                throw new IndexOutOfBoundsException("Index " + index + " is out of range, size = " + size);
            }
            return array[index];
        }

        public void add(int value) {
            if (size == array.length) {
                enLarge();
            }
            array[size++] = value;
        }

        public int removeLast() {
            if (size == 0) {
                throw new NoSuchElementException();
            }
            return array[--size];
        }

        public int size() {
            return size;
        }

        public int[] toArray() {
            return Arrays.copyOf(array, size);
        }

        private void enLarge() {
            int[] newArray = new int[array.length << 1];
            System.arraycopy(array, 0, newArray, 0, size);
            array = newArray;
        }

    }

    static class UndirectedTarjan implements BiconnectedComponent {
        int[] dfn;
        int[] state;
        int[] low;
        int vertexNum;
        int lay;
        int scc;
        IntArrayList stack;

        public UndirectedTarjan(Graph g) {
            vertexNum = g.getVertexNumber();
            dfn = new int[vertexNum];
            state = new int[vertexNum];
            low = new int[vertexNum];
            stack = new IntArrayList();
            for (int i = 0; i < vertexNum; i++) {
                if (state[i] == 0) dfs(g, i, -1);
            }
        }

        void dfs(Graph g, int u, int fa) {
            state[u] = 1;
            dfn[u] = low[u] = ++lay;
            stack.add(u);
            for (Edge e : g.getEdges(u)) {
                if (e.to == fa) continue;
                if (state[e.to] == 0) dfs(g, e.to, u);
                if (state[e.to] == 1) low[u] = Math.min(low[u], low[e.to]);
            }
            if (low[u] == dfn[u]) {
                while (true) {
                    int v = stack.removeLast();
                    low[v] = scc;
                    state[v] = 2;
                    if (v == u) break;
                }
                scc++;
            }
        }


        public int getComponentID(int vertexID) {
            return low[vertexID];
        }


        public int getComponentsNumber() {
            return scc;
        }


        public int[][] getComponents() {
            int[][] ret = new int[scc][];
            IntArrayList[] components = new IntArrayList[scc];
            for (int i = 0; i < scc; i++) components[i] = new IntArrayList();
            for (int i = 0; i < vertexNum; i++) components[low[i]].add(i);
            for (int i = 0; i < scc; i++) ret[i] = components[i].toArray();
            return ret;
        }

    }

    static class Edge {
        public int to;
        public long weight;

        public Edge(int to) {
            this.to = to;
        }

        public Edge(int to, long weight) {
            this(to);
            this.weight = weight;
        }

    }

    static class Graph {
        MyArrayList<Edge>[] g;

        public Graph(int n) {
            g = new MyArrayList[n];
            for (int i = 0; i < n; i++) {
                g[i] = new MyArrayList();
            }
        }

        public void addEdge(int from, int to) {
            g[from].add(new Edge(to));
        }

        public MyArrayList<Edge> getEdges(int from) {
            return g[from];
        }

        public int getVertexNumber() {
            return g.length;
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] inbuf = new byte[1024];
        private int lenbuf = 0;
        private int ptrbuf = 0;

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

        private int readByte() {
            if (lenbuf == -1) throw new UnknownError();
            if (ptrbuf >= lenbuf) {
                ptrbuf = 0;
                try {
                    lenbuf = stream.read(inbuf);
                } catch (IOException e) {
                    throw new UnknownError();
                }
                if (lenbuf <= 0) return -1;
            }
            return inbuf[ptrbuf++];
        }

        public int nextInt() {
            int num = 0, b;
            boolean minus = false;
            while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
            if (b == '-') {
                minus = true;
                b = readByte();
            }

            while (true) {
                if (b >= '0' && b <= '9') {
                    num = num * 10 + (b - '0');
                } else {
                    return minus ? -num : num;
                }
                b = readByte();
            }
        }

    }
}

