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 

#include<bits/stdc++.h>
#define rep(i,j,k) for(int i=(j);i<(k);i++)
#define mp make_pair
#define sz(a) (int)(a).size()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll,int> pii;
typedef long double ld;
typedef pair<double,double> pdd;
//----head----
const int N=200005;
stack<int> s;
vector<int> v[N];
int dfn[N],low[N],instack[N],npoint[N];
int point_cnt[N],edge_cnt[N],iscut[N];
int cnt=0;
int index=0;
vector<int> ans;
vector<pii> edge;
int n,m;
void tarjan(int a,int fa)//��˫��ͨ
{
    dfn[a]=low[a]=++index;
    s.push(a);
    instack[a]=1;
    int child=0;
    for(int i=0;i<v[a].size();i++)
    {
        int point=v[a][i];
        if(point==fa)continue;
        if(!dfn[point])
        {
        	child++;
            tarjan(point,a);
            low[a]=min(low[a],low[point]);
            if(low[point]>=dfn[a])//a��Ϊ��� 
            {
            	iscut[a]=1;
            	cnt++;
        		while(s.top()!=point)
        		{
            		npoint[s.top()]=cnt;
            		instack[s.top()]=0;
            		s.pop();
            		point_cnt[cnt]++;
        		}
        		npoint[s.top()]=cnt;
        		instack[s.top()]=0;
        		s.pop();
        		point_cnt[cnt]++;
        		npoint[a]=cnt;
        		point_cnt[cnt]++;
            }
        }
        else if(instack[point])low[a]=min(low[a],dfn[point]);
    }
    if(fa==-1&&child<2)iscut[a]=0;
}
int main()
{
	scanf("%d%d",&n,&m);
	while(m--)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		v[a].pb(b);
		v[b].pb(a);
		edge.pb(mp(a,b));
	}
	rep(i,1,n+1)if(!dfn[i])tarjan(i,-1);
	//rep(i,1,n+1)printf("%d : %d\n",i,iscut[i]);
	rep(i,0,sz(edge))
	{
		int a=edge[i].first,b=edge[i].second;
		if(iscut[a]&&iscut[b]);
		else if(iscut[a])edge_cnt[npoint[b]]++;
		else if(iscut[b])edge_cnt[npoint[a]]++;
		else if(npoint[a]==npoint[b])edge_cnt[npoint[a]]++;
	}
	rep(i,0,sz(edge))
	{
		int a=edge[i].first,b=edge[i].second;
		//printf("%d %d\n",npoint[a],npoint[b]);
		if(iscut[a]&&iscut[b])continue;
		if(iscut[a])swap(a,b);
		if(iscut[b]||npoint[a]==npoint[b])if(point_cnt[npoint[a]]==edge_cnt[npoint[a]])ans.pb(i+1);
	}
	printf("%d\n",sz(ans));
	rep(i,0,sz(ans))printf("%d ",ans[i]);
	puts("");
	return 0;
}
