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.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.StringTokenizer;

public class F {
	private static boolean debug=false;

	public static void solve(FastScanner fs) {
		int nNodes=fs.nextInt();
		int nEdges=fs.nextInt();
		MagicComponents comps=new MagicComponents(nNodes);
		for (int i=0; i<nEdges; i++) {
			comps.addEdge(fs.nextInt()-1, fs.nextInt()-1);
		}
		comps.run();
		comps.fillBCCs();
		HashSet<Integer>[] nodesInBCC=new HashSet[comps.bccs.size()];
		for (int i=0; i<nodesInBCC.length; i++)
			nodesInBCC[i]=new HashSet<>();
		for (Edge e:comps.allEdges) {
			if (e.bcc==-1)
				continue;
			nodesInBCC[e.bcc].add(e.u);
			nodesInBCC[e.bcc].add(e.v);
		}
		for (ArrayList<Edge> e:comps.bccs) {
			if(debug)System.out.println(e);
		}
		boolean[] okayComps=new boolean[comps.bccs.size()];
		for (int i=0; i<okayComps.length; i++) {
			if(debug)System.out.println("Node in BCC "+i+": "+nodesInBCC[i].size());
			okayComps[i]=(comps.bccs.get(i).size()!=1)&&nodesInBCC[i].size()==comps.bccs.get(i).size();
		}
		if(debug)System.out.println("Okay comps: "+Arrays.toString(okayComps));
		boolean[] okayEdges=new boolean[nEdges];
		for (Edge e:comps.allEdges)
			if (e.bcc!=-1&&okayComps[e.bcc])
				okayEdges[e.id]=true;
		int count=0;
		for (boolean b:okayEdges)
			if (b) count++;
		System.out.println(count);
		for (int i=0; i<nEdges; i++)
			if (okayEdges[i])
				System.out.print((i+1)+" ");
	}

	// # Bi-connected Components
	// Two-Connected Components
	// Articulation or cut points
	// Bridges //$
	static class Edge {
		int u, v, id;
		int bcc=-1;
		
		public Edge(int U, int V, int i) {
			u=U;
			v=V;
			id=i;
		}
		
		public String toString() {
			return "from "+u+" to "+v;
		}
	}
	static class MagicComponents { // Stack Trick!
		int num, n, edges;
		int[] dfsNum, low, vis;
		ArrayList<Integer> cuts;
		ArrayList<Edge> bridges, adj[];
		ArrayList<ArrayList<Edge>> bccs;
		ArrayDeque<Edge> eStack;
		ArrayList<Edge> allEdges=new ArrayList<>();

		MagicComponents(int N) {
			adj=new ArrayList[n=N];
			for (int i=0; i<n; i++)
				adj[i]=new ArrayList<>();
			edges=0;
		}

		void addEdge(int u, int v) {
			if(debug)System.out.println("Adding edge from "+u+" "+v);
			Edge first=new Edge(u, v, edges);
			Edge second=new Edge(v, u, edges++);
			adj[u].add(first);
			adj[v].add(second);
			allEdges.add(first);
			allEdges.add(second);
		}

		void run() {
			vis=new int[n];
			dfsNum=new int[n];
			low=new int[n];
			bridges=new ArrayList<>();
			cuts=new ArrayList<>();
			bccs=new ArrayList<>();
			eStack=new ArrayDeque<>();
			num=0;

			for (int i=0; i<n; i++) {
				if (vis[i]!=0)
					continue;
				dfs(i, -1);
			}
		}

		void dfs(int node, int par) {
			dfsNum[node]=low[node]=num++;
			vis[node]=1;
			int nChild=0;
			for (Edge e:adj[node]) {
				if (e.v==par)
					continue;
				if (vis[e.v]==0) {
					++nChild;
					eStack.push(e);
					dfs(e.v, node);
					low[node]=Math.min(low[node], low[e.v]);
					if (low[e.v]>=dfsNum[node]) {
						if (dfsNum[node]>0||nChild>1)
							cuts.add(node);
						if (low[e.v]>dfsNum[node]) {
							bridges.add(e);
							pop(node);
						}
						else
							pop(node);
					}
				}
				else if (vis[e.v]==1) {
					low[node]=Math.min(low[node], dfsNum[e.v]);
					eStack.push(e);
				}
			}
			vis[node]=2;
		}

		void pop(int u) {
			ArrayList<Edge> list=new ArrayList<>();
			for (;;) {
				Edge e=eStack.pop();
				list.add(e);
				if (e.u==u)
					break;
			}
			bccs.add(list);
		}

		public void fillBCCs() {
			for (int i=0; i<bccs.size(); i++) {
				for (Edge e:bccs.get(i)) {
					e.bcc=i;
				}
			}
		}
		
		// # Make sure to call run before calling this function.
		// Function returns a new graph such that all two connected
		// components are compressed into one node and all bridges
		// in the previous graph are the only edges connecting the
		// components in the new tree.
		// map is an integer array that will store the mapping
		// for each node in the old graph into the new graph. //$
		MagicComponents componentTree(int[] map) {
			boolean[] vis=new boolean[edges];
			for (Edge e:bridges)
				vis[e.id]=true;

			int numComp=0;
			Arrays.fill(map, -1);
			for (int i=0; i<n; ++i) {
				if (map[i]==-1) {
					ArrayDeque<Integer> q=new ArrayDeque<>();
					q.add(i);
					map[i]=numComp;
					while (!q.isEmpty()) {
						int node=q.poll();
						for (Edge e:adj[node]) {
							if (!vis[e.id]&&map[e.v]==-1) {
								vis[e.id]=true;
								map[e.v]=numComp;
								q.add(e.v);
							}
						}
					}
					++numComp;
				}
			}

			MagicComponents g=new MagicComponents(numComp);
			Arrays.fill(vis, false);
			for (int i=0; i<n; ++i) {
				for (Edge e:adj[i]) {
					if (!vis[e.id]&&map[e.v]<map[e.u]) {
						vis[e.id]=true;
						g.addEdge(map[e.v], map[e.u]);
					}
				}
			}

			return g;
		}

		// # Make sure to call run before calling this function.
		// Function returns a new graph such that all biconnected
		// components are compressed into one node. Cut nodes will
		// be in multiple components, so these nodes will also have
		// their own component by themselves. Edges in the graph
		// represent components to articulation points
		// map is an integer array that will store the mapping
		// for each node in the old graph into the new graph.
		// Cut points to their special component, and every other node
		// to their specific component. //$
		MagicComponents bccTree(int[] map) {
			int[] cut=new int[n];
			Arrays.fill(cut, -1);
			int size=bccs.size();
			for (int i:cuts)
				map[i]=cut[i]=size++;
			MagicComponents g=new MagicComponents(size);
			int[] used=new int[n];
			for (int i=0; i<bccs.size(); ++i) {
				ArrayList<Edge> list=bccs.get(i);
				for (Edge e:list) {
					for (int node:new int[]{e.u, e.v}) {
						if (used[node]!=i+1) {
							used[node]=i+1;
							if (cut[node]!=-1)
								g.addEdge(i, cut[node]);
							else
								map[node]=i;
						}
					}
				}
			}
			return g;
		}
	}

	public static void main(String[] args) throws NumberFormatException, IOException {
		FastScanner scanner=new FastScanner(System.in);
		solve(scanner);
	}

	private static class FastScanner {
		BufferedReader br;
		StringTokenizer st;
		public FastScanner(InputStream in) {
			br=new BufferedReader(new InputStreamReader(in));
		}
		String next() {
			while (st==null||!st.hasMoreElements()) {
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
		double nextDouble() {
			return Double.parseDouble(next());
		}
		String nextLine() {
			String str="";
			try {
				str=br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++)
				a[i]=nextInt();
			return a;
		}
		long[] readLongArray(int n) {
			long[] a=new long[n];
			for (int i=0; i<n; i++)
				a[i]=nextLong();
			return a;
		}
	}

}
