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 

#pragma GCC optimize("O3")
#include<stdint.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/rope>
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define VIS(it,con) for(auto it=con.begin();it!=con.end();++it)
#define pob pop_back
#define pf push_front
#define pof pop_front
#define MIN(x,y) (x=min(x,(y)))
#define MAX(x,y) (x=max(x,(y)))
#define mid (l+r>>1)
#define lch (idx*2+1)
#define rch (idx*2+2)
/*****************************************************************************/
#include<bits/stdc++.h>
#define int int_fast64_t
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> VI;
#define REP(i,j,k) for(register int i=(j);i<(k);++i)
#define RREP(i,j,k) for(register int i=(j)-1;i>=(k);--i)
#define ALL(a) a.begin(),a.end()
#define MST(a,v) memset(a,(v),sizeof a)
#define pb push_back
#define F first
#define S second
#define endl '\n'
//																#define __debug
#ifdef __debug
	#define IOS (void)0
	#define de(...) cerr<<__VA_ARGS__
	#define ar(a,s,t) {REP(__i,s,t)de(a[__i]<<' ');de(endl);}
#else
	#define IOS cin.tie(0),cout.tie(0),ios_base::sync_with_stdio(false)
	#define de(...) (void)0
	#define ar(...) (void)0
#endif
/***********************************default***********************************/
const int maxn=1e5+9,maxm=21e5+9;
int n,m,cl=0,bcl=0,dfn[maxn],low[maxn],vis[maxn],bn[maxn];
VI res,vt[maxn],ed[maxn];
vector<pii>G[maxn];
pii eds[maxm];
stack<int>stk;

void dfs(int u,int f){
	dfn[u]=low[u]=cl++;
	vis[u]=1;
	REP(i,0,G[u].size()){
		int v=G[u][i].F;
		if(v==f)continue;
		if(vis[v]){
			if(dfn[u]>dfn[v])stk.push(G[u][i].S);
			MIN(low[u],dfn[v]);
		}else{
			stk.push(G[u][i].S);
			dfs(v,u);
			MIN(low[u],low[v]);
			if(low[v]>=dfn[u]){
				ed[bcl].clear();
				while(1){
					int tt=stk.top();stk.pop();
					ed[bcl].pb(tt);
					if(bn[eds[tt].F]!=bcl)vt[bcl].pb(eds[tt].F),bn[eds[tt].F]=bcl;
					if(bn[eds[tt].S]!=bcl)vt[bcl].pb(eds[tt].S),bn[eds[tt].S]=bcl;
					if(tt==G[u][i].S)break;
				}
				++bcl;
			}
		}
	}
}

main(){
	IOS;
	cin>>n>>m;
	REP(i,0,m){
		int a,b;cin>>a>>b,--a,--b;
		G[a].pb(pii(b,i)),G[b].pb(pii(a,i));
		eds[i]=pii(a,b);
	}
	MST(vis,0);
	MST(bn,-1);
	REP(i,0,n)if(!vis[i])dfs(0,-1);
//	ar(dfn,0,n);
//	ar(low,0,n);
//	de(bcl<<endl);
//	REP(i,0,bcl){
//		REP(j,0,ed[i].size())cout<<ed[i][j]<<" ";
//		cout<<endl;
//	}
	REP(i,0,bcl){
		if(vt[i].size()==ed[i].size()){
			REP(j,0,ed[i].size()){
				res.pb(ed[i][j]);
			}
		}
	}
	sort(ALL(res));
	cout<<res.size()<<endl;
	REP(i,0,res.size())cout<<res[i]+1<<" ";
}