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 = 100005, M = 200005;
int n, m, tot = 1, Next[M], to[M], head[M], pre[N], low[N], tim = 0, ss[N],
          re[N], cur = 0, co[N], now = 0;
bool bo[M];
stack<int> s;
inline void add(int x, int y) {
  Next[++tot] = head[x];
  to[tot] = y;
  head[x] = tot;
}
inline void dfs(int x, int fa) {
  int i, j, ct, tp;
  pre[x] = low[x] = ++tim;
  for (i = head[x]; i; i = Next[i])
    if (to[i] != fa && !bo[i]) {
      bo[i] = bo[i ^ 1] = 1;
      s.push(i);
      if (!pre[to[i]]) {
        dfs(to[i], x);
        low[x] = min(low[x], low[to[i]]);
        if (low[to[i]] >= pre[x]) {
          ct = tp = 0;
          ++now;
          while (s.top() != i) {
            if (co[to[s.top()]] != now) co[to[s.top()]] = now, ct++;
            if (co[to[s.top() ^ 1]] != now) co[to[s.top() ^ 1]] = now, ct++;
            ss[++tp] = s.top();
            s.pop();
          }
          if (co[to[i]] != now) co[to[i]] = now, ct++;
          if (co[to[i ^ 1]] != now) co[to[i ^ 1]] = now, ct++;
          ss[++tp] = i;
          s.pop();
          if (pre[x] == low[to[i]] && ct == tp)
            for (j = 1; j <= tp; j++) re[++re[0]] = ss[j];
        }
      } else
        low[x] = min(low[x], pre[to[i]]);
    }
}
int main() {
  int i, x, y;
  scanf("%d%d", &n, &m);
  memset(co, 0, sizeof co);
  for (i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    add(x, y);
    add(y, x);
  }
  for (i = 1; i <= n; i++)
    if (!pre[i]) dfs(i, 0);
  printf("%d\n", re[0]);
  sort(re + 1, re + re[0] + 1);
  for (i = 1; i <= re[0]; i++) printf("%d ", re[i] >> 1);
}
