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>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define popb pop_back
#define popf pop_front
#define all(v) v.begin(), v.end()
#define fori(i, j, k) for (int i = (j); i < (int)(k); i++)
#define forb(i, j, k) for (int i = (j); i >= (int)k; i--)
#define lchild(ind) 2 * ind + 1
#define rchild(ind) 2 * ind + 2
#define bug(val) cout << "# " << val << endl;
#define bugs(val) cout << '_' << val;
#define bugl(val) cout << "## " << val << endl;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef pair<int, pll> pip;
typedef pair<ll, pll> plp;
typedef pair<pll, int> ppi;
typedef pair<pll, ll> ppl;
typedef pair<pll, pll> ppp;
typedef vector<int> vi;
typedef vector<ll> vll;

const int maxn = 1e5 + 1, maxb = 20;
const ll inf = 2e18, mod = 1e9 + 7;

#define tree TREE

int n, m, dp[maxn], pare[maxn], par[maxb][maxn], mx[maxb][maxn], h[maxn], p[maxn];
vi backe, vec;
vector<pii> graph[maxn], tree[maxn];
pii edge[maxn];
bool visited[maxn], ans[maxn];

void dfs(int u, int preve)
{
	visited[u] = true;
	pare[u] = preve;
	for (pii i : graph[u])
	{
		if (!visited[i.ff])
		{
			tree[u].pb(i);
			h[i.ff] = h[u] + 1;
			p[i.ff] = u;
			dfs(i.ff, i.ss);
		}
		else if (i.ss != preve && h[i.ff] < h[u])
		{
			dp[i.ff]--;
			dp[u]++;
			backe.pb(i.ss);
		}
	}
}

void relax(int u)
{
	for (pii i : tree[u])
	{
		relax(i.ff);
		dp[u] += dp[i.ff];
	}
}

void prepLCA(int u, int prev)
{
	visited[u] = true;
	for (pii i : graph[u])
		if (!visited[i.ff])
		{
			par[0][i.ff] = u;
			mx[0][i.ff] = dp[i.ff];
			fori (j, 1, maxb)
			{
				par[j][i.ff] = par[j - 1][par[j - 1][i.ff]];
				mx[j][i.ff] = max(mx[j - 1][i.ff], mx[j - 1][par[j - 1][i.ff]]);
			}
			prepLCA(i.ff, u);
		}
}

int parent(int u, int h)
{
	fori (i, 0, maxb)
		if ((h >> i) & 1)
			u = par[i][u];
	return u;
}

int getMX(int u, int h)
{
	int res = -mod;
	fori (i, 0, maxb)	
		if ((h >> i) & 1)
		{
			res = max(res, mx[i][u]);
			u = par[i][u];
		}
	return res;
}

void add(int u, int h)
{
	while (h--)
	{
		ans[pare[u]] = true;
		u = p[u];
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	cin >> n >> m;
	int u, v;
	fori (i, 0, m)
	{
		cin >> u >> v;
		u--;
		v--;
		graph[u].pb(mp(v, i));
		graph[v].pb(mp(u, i));
		edge[i] = mp(u, v);
	}
	dfs(0, -1);
	relax(0);
	memset(visited, false, sizeof(visited));
	prepLCA(0, -1);
	for (int i : backe)
	{
		u = edge[i].ff;
		v = edge[i].ss;
		if (h[u] < h[v])
			swap(u, v);
		if (getMX(u, h[u] - h[v]) == 1)
		{
			add(u, h[u] - h[v]);
			ans[i] = true;
		}
	}
	fori (i, 0, m)
		if (ans[i])
			vec.pb(i);
	cout << vec.size() << endl;
	for (int i : vec)
		cout << i + 1 << ' ';
	cout << endl;
}
