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 

// practice with rainboy
import java.io.*;
import java.util.*;

public class CF962F extends PrintWriter {
	CF962F() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		CF962F o = new CF962F(); o.main(); o.flush();
	}

	int[] dsu, back;
	int find(int i) {
		return dsu[i] < 0 ? i : (dsu[i] = find(dsu[i]));
	}
	void join(int i, int j) {
		i = find(i);
		j = find(j);
		if (i == j)
			return;
		if (dsu[i] > dsu[j]) {
			dsu[i] = j;
			back[j] += back[i];
		} else {
			if (dsu[i] == dsu[j])
				dsu[i]--;
			dsu[j] = i;
			back[i] += back[j];
		}
	}

	int[] next, hh; int l_ = 1;
	int link(int l, int h) { next[l_] = l; hh[l_] = h; return l_++; }
	int[] ij;
	int[] ao;
	int[] ta, tb; int time;
	boolean[] cut;
	void init(int n, int m) {
		next = new int[1 + m * 2];
		hh = new int[1 + m * 2];
		ij = new int[m];
		ao = new int[n];
		ta = new int[n];
		tb = new int[n];
		cut = new boolean[n];
		dsu = new int[m]; Arrays.fill(dsu, -1);
		back = new int[m];
	}
	void dfs(int f, int i) {
		ta[i] = tb[i] = ++time;
		int c = 0;
		for (int l = ao[i]; l != 0; l = next[l]) {
			int h = hh[l];
			if (h != f) {
				int j = i ^ ij[h];
				if (ta[j] == 0) {
					c++;
					dfs(h, j);
					tb[i] = Math.min(tb[i], tb[j]);
					if (tb[j] < ta[i])
						join(f, h);
					else if (f != -1)
						cut[i] = true;
				} else if (ta[j] < ta[i]) {
					tb[i] = Math.min(tb[i], ta[j]);
					back[h] = 1;
					join(f, h);
				}
			}
		}
		if (f == -1 && c > 1)
			cut[i] = true;
	}

	void main() {
		int n = sc.nextInt();
		int m = sc.nextInt();
		init(n, m);
		for (int h = 0; h < m; h++) {
			int i = sc.nextInt() - 1;
			int j = sc.nextInt() - 1;
			ij[h] = i ^ j;
			ao[i] = link(ao[i], h);
			ao[j] = link(ao[j], h);
		}
		for (int i = 0; i < n; i++)
			if (ta[i] == 0)
				dfs(-1, i);
		int[] ans = new int[m];
		int cnt = 0;
		for (int h = 0; h < m; h++)
			if (back[find(h)] == 1)
				ans[cnt++] = h;
		println(cnt);
		for (int h = 0; h < cnt; h++)
			print(ans[h] + 1 + " ");
		println();
	}
}
