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 a, b, c, d, e, i, j, zx, xc, lf[100009], rg[100009], tim, lc[100009][19],
    lcmax[100009][19], cnt, pas[100009], k[100009], ans[100009], p[100009], pi,
    jm[100009];
pair<int, int> ed[100009];
vector<int> v[100009], msh[100009], shv[100009];
vector<pair<int, int> > vv;
set<pair<int, int> > s;
set<pair<int, int> >::iterator t;
map<pair<int, int>, bool> m;
int bo[100009];
void dfs(int q, int w) {
  tim++;
  lc[q][0] = w;
  for (int hh = 1; hh <= 17; hh++) lc[q][hh] = lc[lc[q][hh - 1]][hh - 1];
  lf[q] = rg[q] = tim;
  k[lf[q]] = q;
  bo[q] = cnt;
  for (vector<int>::iterator it = v[q].begin(); it != v[q].end(); it++) {
    if ((*it) == w) continue;
    if (bo[(*it)] == cnt) {
      if (lf[(*it)] < lf[q]) {
        msh[q].push_back((*it));
        shv[(*it)].push_back(q);
        vv.push_back(make_pair((*it), q));
      }
      continue;
    }
    dfs((*it), q);
    if (rg[q] < rg[(*it)]) rg[q] = rg[(*it)];
  }
}
bool anc(int q, int w) {
  if (lf[q] <= lf[w] && rg[q] >= rg[w])
    return 1;
  else
    return 0;
}
void dfs2(int q, int w) {
  bo[q] = cnt;
  t = s.lower_bound(make_pair(lf[q], 0));
  if (t == s.end()) {
    ans[q] = 0;
  } else {
    if ((*t).first <= rg[q]) {
      ans[q] = m[make_pair(k[(*t).second], k[(*t).first])];
    } else {
      ans[q] = 0;
    }
  }
  for (vector<int>::iterator it = shv[q].begin(); it != shv[q].end(); it++) {
    s.insert(make_pair(lf[(*it)], lf[q]));
  }
  for (vector<int>::iterator it = v[q].begin(); it != v[q].end(); it++) {
    if (bo[(*it)] == cnt) continue;
    dfs2((*it), q);
  }
  for (vector<int>::iterator it = shv[q].begin(); it != shv[q].end(); it++) {
    s.erase(s.lower_bound(make_pair(lf[(*it)], lf[q])));
  }
}
void dfs3(int q, int w) {
  bo[q] = cnt;
  for (vector<int>::iterator it = v[q].begin(); it != v[q].end(); it++) {
    if (bo[(*it)] == cnt) continue;
    dfs3((*it), q);
    jm[q] += jm[(*it)];
  }
}
void dfs4(int q, int w) {
  bo[q] = cnt;
  lcmax[q][0] = jm[q];
  for (int hh = 1; hh <= 17; hh++)
    lcmax[q][hh] = max(lcmax[q][hh - 1], lcmax[lc[q][hh - 1]][hh - 1]);
  for (vector<int>::iterator it = v[q].begin(); it != v[q].end(); it++) {
    if (bo[(*it)] == cnt) continue;
    dfs4((*it), q);
  }
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> a >> b;
  for (i = 1; i <= b; i++) {
    cin >> c >> d;
    ed[i].first = c;
    ed[i].second = d;
    v[c].push_back(d);
    v[d].push_back(c);
  }
  cnt++;
  for (i = 1; i <= a; i++) {
    if (bo[i] == cnt) continue;
    dfs(i, 0);
  }
  for (i = 0; i < vv.size(); i++) {
    c = vv[i].first;
    d = vv[i].second;
    jm[c]--;
    jm[d]++;
  }
  cnt++;
  for (i = 1; i <= a; i++) {
    if (bo[i] == cnt) continue;
    dfs3(i, 0);
  }
  cnt++;
  for (i = 1; i <= a; i++) {
    if (bo[i] == cnt) continue;
    dfs4(i, 0);
  }
  for (i = 0; i < vv.size(); i++) {
    c = vv[i].first;
    d = vv[i].second;
    e = 0;
    for (int hh = 17; hh >= 0; hh--) {
      if (lc[d][hh] != 0 && anc(lc[d][hh], c) == 0) {
        if (e < lcmax[d][hh]) e = lcmax[d][hh];
        d = lc[d][hh];
      }
    }
    if (e < lcmax[d][0]) e = lcmax[d][0];
    if (e <= 1) {
      m[vv[i]] = 1;
    }
  }
  cnt++;
  for (i = 1; i <= a; i++) {
    if (bo[i] == cnt) continue;
    dfs2(i, 0);
  }
  for (i = 1; i <= b; i++) {
    c = ed[i].first;
    d = ed[i].second;
    if (lf[c] > lf[d]) swap(c, d);
    if (ans[d] == 1) {
      pi++;
      p[pi] = i;
    }
  }
  cout << pi << endl;
  for (i = 1; i <= pi; i++) {
    cout << p[i] << " ";
  }
  return 0;
}
