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>
using namespace std;
const int N = 1e5 + 5, LOG = 17;
int par[N][LOG], mx[N][LOG], U[N], V[N], h[N], mark[N], val[N];
map<int, int> id[N];
vector<int> g[N];
int dfs(int v, int p) {
  mark[v] = 1, h[v] = h[p] + 1;
  for (int u : g[v])
    if (u != p) {
      if (!mark[u])
        val[v] += dfs(u, v);
      else if (mark[u] != 2)
        val[v]++, val[u]--;
    }
  par[v][0] = p, mx[v][0] = val[v];
  for (int i = 1; i < LOG; i++)
    par[v][i] = par[par[v][i - 1]][i - 1],
    mx[v][i] = max(mx[v][i - 1], mx[par[v][i - 1]][i - 1]);
  mark[v] = 2;
  return val[v];
}
int getmax(int v, int height) {
  int res = 0;
  for (int i = 0; height; height >>= 1, i++)
    if (height & 1) res = max(res, mx[v][i]), v = par[v][i];
  return res;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> U[i] >> V[i];
    g[U[i]].push_back(V[i]), g[V[i]].push_back(U[i]);
    id[U[i]][V[i]] = id[V[i]][U[i]] = i;
  }
  for (int i = 1; i <= n; i++)
    if (!mark[i]) dfs(i, i);
  for (int i = 1; i < LOG; i++) {
    for (int v = 1; v <= n; v++)
      par[v][i] = par[par[v][i - 1]][i - 1],
      mx[v][i] = max(mx[v][i - 1], mx[par[v][i - 1]][i - 1]);
  }
  vector<int> ans;
  for (int i = 0; i < m; i++) {
    int u = U[i], v = V[i];
    if (h[u] > h[v]) swap(u, v);
    if (h[v] - h[u] == 1) continue;
    if (getmax(v, h[v] - h[u]) != 1) continue;
    ans.push_back(i + 1);
    while (v != u) ans.push_back(id[v][par[v][0]] + 1), v = par[v][0];
  }
  sort(ans.begin(), ans.end());
  cout << ans.size() << "\n";
  for (int i : ans) cout << i << " ";
  cout << "\n";
  return 0;
}
