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 MAXN = 1e5 + 7, MAXM = 5e6 + 7;
inline int R() {
  int rt = 0;
  char ch = getchar();
  bool isn = false;
  for (; ch < '0' || ch > '9'; ch = getchar()) isn = ch == '-' ? true : isn;
  for (; ch >= '0' && ch <= '9'; ch = getchar()) rt = rt * 10 + ch - '0';
  return isn ? -rt : rt;
}
struct Edge {
  int to, nxt;
  bool br;
} o[MAXM];
int nu = 1;
struct Node {
  int fe;
  int dfn, low;
  int blk;
} a[MAXN];
int nt, nb;
int bsz[MAXN], esz[MAXN];
void Addedge(int fm, int de) {
  o[++nu].to = de, o[nu].nxt = a[fm].fe, a[fm].fe = nu;
  swap(fm, de);
  o[++nu].to = de, o[nu].nxt = a[fm].fe, a[fm].fe = nu;
}
void Dfs(int nf, int nfa) {
  a[nf].dfn = ++nt, a[nf].low = nt;
  for (int ne = a[nf].fe; ne; ne = o[ne].nxt) {
    if (o[ne].to == nfa) continue;
    if (!a[o[ne].to].dfn) {
      Dfs(o[ne].to, nf);
      a[nf].low = min(a[nf].low, a[o[ne].to].low);
      if (a[o[ne].to].low > a[nf].dfn) o[ne].br = true, o[ne ^ 1].br = true;
    } else
      a[nf].low = min(a[nf].low, a[o[ne].to].dfn);
  }
}
void Fnd(int nf) {
  a[nf].blk = nb, ++bsz[nb];
  for (int ne = a[nf].fe; ne; ne = o[ne].nxt) {
    if (a[o[ne].to].blk || o[ne].br) continue;
    Fnd(o[ne].to);
  }
}
vector<int> ans;
int main() {
  int n = R(), m = R();
  for (int i = 1; i <= m; ++i) Addedge(R(), R());
  for (int i = 1; i <= n; ++i)
    if (!a[i].dfn) Dfs(i, 0);
  for (int i = 1; i <= n; ++i)
    if (!a[i].blk) ++nb, Fnd(i);
  for (int i = 1; i <= m; ++i) {
    int ne = i * 2;
    if (o[ne].br) continue;
    ++esz[a[o[ne].to].blk];
  }
  for (int i = 1; i <= m; ++i) {
    int ne = i * 2;
    if (o[ne].br) continue;
    if (esz[a[o[ne].to].blk] == bsz[a[o[ne].to].blk]) ans.push_back(i);
  }
  printf("%d\n", ans.size());
  for (int i = 0; i < ans.size(); ++i) printf("%d ", ans[i]);
  return 0;
}
