#include <bits/stdc++.h>
using namespace std;
struct Edge {
  int u, v;
  Edge() {}
  Edge(int u, int v) : u(u), v(v) {}
};
const int maxn = 100001;
int pre[maxn], iscut[maxn], bccno[maxn], dfs_clock, bcc_cnt;
vector<pair<int, int> > G[maxn];
vector<int> bcc[maxn];
int edge_cnt[maxn];
stack<Edge> S;
int n, m, x[maxn], y[maxn];
int vis[maxn];
int ans, ok[maxn];
int dfs(int u, int fa) {
  int lowu = pre[u] = ++dfs_clock;
  int child = 0;
  for (auto p : G[u]) {
    int v = p.first;
    Edge e(u, v);
    if (!pre[v]) {
      S.push(e);
      child++;
      int lowv = dfs(v, u);
      lowu = min(lowu, lowv);
      if (lowv >= pre[u]) {
        iscut[u] = true;
        bcc_cnt++;
        while (1) {
          Edge x = S.top();
          S.pop();
          if (bccno[x.u] != bcc_cnt) {
            bcc[bcc_cnt].push_back(x.u);
            bccno[x.u] = bcc_cnt;
          }
          if (bccno[x.v] != bcc_cnt) {
            bcc[bcc_cnt].push_back(x.v);
            bccno[x.v] = bcc_cnt;
          }
          if (x.u == u && x.v == v) break;
        }
      }
    } else if (pre[v] < pre[u] && v != fa) {
      S.push(e);
      lowu = min(lowu, pre[v]);
    }
  }
  if (fa < 0 && child == 1) iscut[u] = 0;
  return lowu;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &x[i], &y[i]);
    G[x[i]].emplace_back(y[i], i);
    G[y[i]].emplace_back(x[i], i);
  }
  for (int i = 1; i <= n; i++) {
    if (!bccno[i]) dfs(i, -1);
  }
  vector<int> edges;
  for (int i = 1; i <= bcc_cnt; i++) {
    for (auto x : bcc[i]) bccno[x] = i;
    edges.clear();
    for (auto x : bcc[i]) {
      for (auto y : G[x]) {
        if (bccno[y.first] == i) {
          edges.push_back(y.second);
        }
      }
    }
    if (edges.size() == bcc[i].size() * 2) {
      for (auto x : edges) ok[x] = 1;
    }
  }
  for (int i = 1; i <= m; i++) ans += ok[i];
  printf("%d\n", ans);
  for (int i = 1; i <= m; i++)
    if (ok[i]) printf("%d ", i);
  return 0;
}
