#include <bits/stdc++.h>
using namespace std;
struct ee {
  int to, nt;
} e[404040];
int n, m, ct = 1, tt, a[202020], bl[202020], hd[202020], xu[202020], lw[202020],
          sk[202020], tp, nw, ne, nd;
bool vis[404040];
vector<int> ans;
void add(int x, int y) {
  ct++;
  e[ct].to = y;
  e[ct].nt = hd[x];
  hd[x] = ct;
}
void dfs(int x, int y) {
  tt++;
  xu[x] = tt;
  lw[x] = tt;
  for (int i = hd[x]; i; i = e[i].nt) {
    int z = e[i].to;
    if (z == y || vis[i]) {
      continue;
    }
    vis[i] = true;
    vis[i ^ 1] = true;
    tp++;
    sk[tp] = i;
    if (!xu[z]) {
      dfs(z, x);
      lw[x] = min(lw[x], lw[z]);
      if (lw[z] >= xu[x]) {
        nw++;
        int ppp;
        ne = 0;
        nd = 0;
        do {
          ppp = sk[tp];
          tp--;
          if (bl[e[ppp].to] != nw) {
            bl[e[ppp].to] = nw;
            nd++;
          }
          if (bl[e[ppp ^ 1].to] != nw) {
            bl[e[ppp ^ 1].to] = nw;
            nd++;
          }
          ne++;
          a[ne] = ppp;
        } while (ppp != i);
        if (nd == ne) {
          for (int i = 1; i <= ne; i++) {
            ans.push_back(a[i] / 2);
          }
        }
      }
    } else {
      lw[x] = min(lw[x], xu[z]);
    }
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    add(x, y);
    add(y, x);
  }
  for (int i = 1; i <= n; i++) {
    if (!xu[i]) {
      dfs(i, 0);
    }
  }
  sort(ans.begin(), ans.end());
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i] << ' ';
  }
  cout << endl;
  return 0;
}
