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.util.*;
import java.math.*;
import java.io.*;

public class CF962F implements Runnable {
	class Graph {
		class Edge {
			int v, id;
			public Edge(int v, int id) {
				this.v = v;
				this.id = id;
			}
		}

		boolean[] simpleEdges, bridges, visited;
		List<Edge>[] adj;
		int[] pre, low;
		boolean[] art;
		int cnt, n, e;
		Set<Integer> edges, nodes;

		public Graph(int nn, int ee) {
			e = ee;
			adj = new ArrayList[n = nn];
			for(int i = 0 ; i < n ; i++)
				adj[i] = new ArrayList<>();
		}

		void add(int u, int v, int i) { adj[u].add(new Edge(v, i));  adj[v].add(new Edge(u, i)); }

		void findBridges() {
			cnt = 0;
			pre = new int[n];
			low = new int[n];
			Arrays.fill(pre, -1);
			art = new boolean[n];
			bridges = new boolean[e];
			for(int i = 0 ; i < n ; i++)
				if(pre[i] == -1)
					dfs(i, i, e);
		}

		int dfs(int u, int p, int id) {
			if(pre[u] != -1) {
				low[p] = Math.min(low[p],  pre[u]);
				return low[p];
			}
			pre[u] = cnt++;
			low[u] = pre[u];
			for(Edge e : adj[u]) {
				if(e.id == id)
					continue;
				if(dfs(e.v, u, e.id) < 0) {
					low[u] = Math.min(low[u],  low[e.v]);
					if(low[e.v] == pre[e.v]) // found bridge
						bridges[e.id] = true;
				}
			}
			return -1;
		}

		List<Integer> solve() {
			simpleEdges = new boolean[e];
			for(int i = 0 ; i < e ; i++)
				simpleEdges[i] = !bridges[i];
			visited = new boolean[n];
			for(int i = 0 ; i < n ; i++) {
				if(!visited[i]) {
					visited[i] = true;
					nodes = new HashSet<>();
					edges = new HashSet<>();
					dfs(i);
					if(edges.size() != nodes.size()) {
						for(int id : edges)
							simpleEdges[id] = false;
					}
				}
			}
			List<Integer> res = new ArrayList<>();
			for(int i = 0 ; i < e ; i++)
				if(simpleEdges[i])
					res.add(i + 1);
			return res;
		}

		void dfs(int u) {
			nodes.add(u);
			for(Edge e : adj[u]) {
				if(!bridges[e.id]) {
					edges.add(e.id);
					if(!visited[e.v]) {
						visited[e.v] = true;
						dfs(e.v);
					}
				}
			}
		}
	}

	final int MOD = (int) 1e9 + 7;
	final double ERROR = 1e-9;
	final double oo = 1e50;

	public void run() {
		SuperScanner scan = new SuperScanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = scan.nextInt(), e = scan.nextInt();
		Graph g = new Graph(n, e);
		for(int i = 0 ; i < e ; i++) {
			int u = scan.nextInt() - 1;
			int v = scan.nextInt() - 1;
			g.add(u, v, i);
		}
		g.findBridges();
		List<Integer> res = g.solve();
		out.println(res.size());
		for(int i = 0 ; i < res.size() ; i++)
			out.print(res.get(i) + " ");
		out.close();
	}



	class SuperScanner {
		public int BS = 1 << 16;
		public char NC = (char) 0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public SuperScanner() {
			in = new BufferedInputStream(System.in, BS);
		}

		public SuperScanner(String s) throws FileNotFoundException {
			in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
		}

		public char nextChar() {
			while (bId == size) {
				try {
					size = in.read(buf);
				} catch (Exception e) {
					return NC;
				}
				if (size == -1)
					return NC;
				bId = 0;
			}
			return (char) buf[bId++];
		}

		public int nextInt() {
			return (int) nextLong();
		}

		public long nextLong() {
			num = 1;
			boolean neg = false;
			if (c == NC)
				c = nextChar();
			for (; (c < '0' || c > '9'); c = nextChar()) {
				if (c == '-')
					neg = true;
			}
			long res = 0;
			for (; c >= '0' && c <= '9'; c = nextChar()) {
				res = (res << 3) + (res << 1) + c - '0';
				num *= 10;
			}
			return neg ? -res : res;
		}

		public double nextDouble() {
			double cur = nextLong();
			return c != '.' ? cur : cur + nextLong() / num;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while (c <= 32)
				c = nextChar();
			while (c > 32) {
				res.append(c);
				c = nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while (c <= 32)
				c = nextChar();
			while (c != '\n') {
				res.append(c);
				c = nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if (c > 32)
				return true;
			while (true) {
				c = nextChar();
				if (c == NC)
					return false;
				else if (c > 32)
					return true;
			}
		}
	}

	public static void main(String[] args) {
		new Thread(null, new CF962F(), "_cf", 1 << 28).start();
	}
}
