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 + 10;
struct graph {
  int n, m;
  int v[N][2];
  vector<int> e[N];
  int depth[N];
  int pa[N][20], pe[N];
  int f[N];
  int ans[N];
  int in_tree[N], sub[N];
  int LCA(int x, int y) {
    if (depth[x] < depth[y]) swap(x, y);
    for (int i = 0, val = depth[x] - depth[y]; val; i++, val >>= 1)
      if (val & 1) x = pa[x][i];
    if (x == y) return x;
    for (int i = int(log2(depth[x])); i >= 0; i--)
      if (pa[x][i] != pa[y][i]) x = pa[x][i], y = pa[y][i];
    return pa[x][0];
  }
  void prepare() {
    cin >> n >> m;
    for (int i = 1; i <= m; i++) {
      int x, y;
      cin >> x >> y;
      v[i][0] = x;
      v[i][1] = y;
      e[x].push_back(i);
      e[y].push_back(i);
    }
  }
  int q[N];
  void BFS(int st) {
    static int top = 1, bot = 0;
    q[++bot] = st;
    pa[st][0] = 0;
    depth[st] = 1;
    while (top <= bot) {
      int x = q[top++];
      for (auto i : e[x]) {
        int y = v[i][0] + v[i][1] - x;
        if (depth[y]) continue;
        pa[y][0] = x;
        pe[y] = i;
        depth[y] = depth[x] + 1;
        q[++bot] = y;
      }
    }
  }
  void answer() {
    prepare();
    for (int i = 1; i <= n; i++)
      if (!depth[i]) BFS(i);
    for (int j = 1; j < 20; j++)
      for (int i = 1; i <= n; i++) pa[i][j] = pa[pa[i][j - 1]][j - 1];
    for (int i = 1; i <= n; i++) in_tree[pe[i]] = 1;
    for (int i = 1; i <= m; i++)
      if (!in_tree[i]) {
        sub[v[i][0]]++;
        sub[v[i][1]]++;
        sub[LCA(v[i][0], v[i][1])] -= 2;
      }
    for (int i = n; i >= 1; i--) {
      int x = q[i];
      sub[pa[x][0]] += sub[x];
    }
    for (int i = 1; i <= n; i++) {
      int x = q[i];
      f[x] = f[pa[x][0]];
      if (sub[x] == 1)
        f[x]++;
      else
        f[x] = 0;
    }
    for (int i = 1; i <= m; i++)
      if (!in_tree[i]) {
        int z = LCA(v[i][0], v[i][1]);
        if (f[v[i][0]] < depth[v[i][0]] - depth[z]) continue;
        if (f[v[i][1]] < depth[v[i][1]] - depth[z]) continue;
        ans[i] = 1;
      }
    memset(sub, 0, sizeof(sub));
    for (int i = 1; i <= m; i++)
      if (ans[i]) {
        sub[v[i][0]]++;
        sub[v[i][1]]++;
        sub[LCA(v[i][0], v[i][1])] -= 2;
      }
    for (int i = n; i >= 1; i--) {
      int x = q[i];
      if (sub[x] == 1) ans[pe[x]] = 1;
      sub[pa[x][0]] += sub[x];
    }
    int nans = count(ans + 1, ans + m + 1, 1);
    cout << nans << '\n';
    for (int i = 1; i <= m; i++)
      if (ans[i]) cout << i << " ";
  }
} mgr;
int main() { mgr.answer(); }
