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;
int head[100005], v[100005 * 2], suc[100005 * 2], en = 1;
void addedge(int iu, int iv) {
  en++;
  v[en] = iv;
  suc[en] = head[iu];
  head[iu] = en;
}
int pre[100005], iscut[100005], bccno[100005], dfs_clk, bcc_cnt;
int st[100005], ts;
vector<int> bcc[100005];
int num[100005];
int dfs(int s, int fa) {
  int lows = pre[s] = ++dfs_clk;
  int ch = 0;
  for (int i = head[s]; i; i = suc[i]) {
    if (!pre[v[i]]) {
      st[++ts] = i;
      ch++;
      int lowv = dfs(v[i], s);
      lows = min(lows, lowv);
      if (lowv >= pre[s]) {
        iscut[s] = 1;
        bcc_cnt++;
        bcc[bcc_cnt].clear();
        while (1) {
          int x = st[ts--];
          for (int y = 0; y <= 1; y++)
            if (bccno[v[x ^ y]] != bcc_cnt) {
              bccno[v[x ^ y]] = bcc_cnt;
              num[bcc_cnt]++;
            }
          bcc[bcc_cnt].push_back(x >> 1);
          if (x == i) break;
        }
      }
    } else if (pre[v[i]] < pre[s] && v[i] != fa) {
      st[++ts] = i;
      lows = min(lows, pre[v[i]]);
    }
  }
  if (fa < 0 && ch == 1) iscut[s] = 0;
  return lows;
}
int ans[100005], ans_cnt;
int main() {
  int i, j, k;
  int n, m, iv, iu;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= m; i++) {
    scanf("%d%d", &iu, &iv);
    addedge(iu, iv);
    addedge(iv, iu);
  }
  for (i = 1; i <= n; i++)
    if (!pre[i]) dfs(i, -1);
  for (i = 1; i <= bcc_cnt; i++)
    if (bcc[i].size() == num[i])
      for (j = 0; j < bcc[i].size(); j++) ans[++ans_cnt] = bcc[i][j];
  sort(ans + 1, ans + ans_cnt + 1);
  printf("%d\n", ans_cnt);
  for (i = 1; i <= ans_cnt; i++) printf("%d ", ans[i]);
  return 0;
}
