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;
template <typename tp>
void read(tp& dig) {
  char ch = getchar();
  dig = 0;
  int flag = 0;
  while (!isdigit(ch)) {
    if (ch == '-') flag = 1;
    ch = getchar();
  }
  while (isdigit(ch)) dig = dig * 10 + ch - '0', ch = getchar();
  if (flag) dig = -dig;
}
struct edge {
  int u, v, id;
} tmp;
stack<edge> s;
vector<int> bcc[150010], bcce[150010];
int bcc_cnt, dfs_clock, bl[150010], icv[150010];
int fst[150010], nxt[300010], to[300010], id[300010];
int n, m, lnum, pre[150010], sum[150010], ans[150010];
inline void add_edge(int u, int v, int k) {
  nxt[++lnum] = fst[u];
  fst[u] = lnum;
  to[lnum] = v;
  id[lnum] = k;
  nxt[++lnum] = fst[v];
  fst[v] = lnum;
  to[lnum] = u;
  id[lnum] = k;
}
inline int dfs(int u, int fa) {
  int lu = ++dfs_clock, ss = 0;
  pre[u] = lu;
  for (int i = fst[u]; i; i = nxt[i]) {
    edge e = (edge){u, to[i], id[i]};
    if (!pre[to[i]]) {
      s.push(e);
      ++ss;
      int lv = dfs(to[i], u);
      lu = min(lu, lv);
      if (lv >= pre[u]) {
        icv[u] = 1;
        ++bcc_cnt;
        bcc[bcc_cnt].clear();
        for (;;) {
          tmp = s.top();
          s.pop();
          bcce[bcc_cnt].push_back(tmp.id);
          if (bl[tmp.u] != bcc_cnt) {
            bcc[bcc_cnt].push_back(tmp.u);
            bl[tmp.u] = bcc_cnt;
          }
          if (bl[tmp.v] != bcc_cnt) {
            bcc[bcc_cnt].push_back(tmp.v);
            bl[tmp.v] = bcc_cnt;
          }
          if (tmp.u == u && tmp.v == to[i]) break;
        }
      }
    } else if (pre[to[i]] < pre[u] && to[i] != fa)
      s.push(e), lu = min(lu, pre[to[i]]);
  }
  return lu;
}
int main() {
  read(n);
  read(m);
  for (int i = 1, x, y; i <= m; ++i) {
    read(x);
    read(y);
    add_edge(x, y, i);
  }
  dfs(1, 0);
  for (int i = 1; i <= bcc_cnt; ++i) {
    int l1 = bcc[i].size();
    int l2 = bcce[i].size();
    if (l1 != l2) continue;
    for (int j = 0; j < l2; ++j) ans[++ans[0]] = bcce[i][j];
  }
  sort(ans + 1, ans + ans[0] + 1);
  printf("%d\n", ans[0]);
  for (int i = 1; i <= ans[0]; ++i) printf("%d ", ans[i]);
  printf("\n");
  return 0;
}
