#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;
}
