#include <bits/stdc++.h>
using namespace std;
struct edge {
  int to, nxt;
};
int head[100010], cnt;
int ans;
edge e[200010];
int dfn[100010], low[100010], ind;
int stk[200010], top;
int col[100010], num;
int deg[100010];
bool ok[100010];
int n, m;
void addedge(int a, int b) {
  e[cnt].to = b;
  e[cnt].nxt = head[a];
  head[a] = cnt++;
  deg[a]++;
}
void tarjan(int x, int p) {
  dfn[x] = low[x] = ++ind;
  for (int i = head[x]; i != -1; i = e[i].nxt) {
    int y = e[i].to;
    if (y == p) continue;
    if (!dfn[y]) {
      stk[++top] = i;
      tarjan(y, x);
      low[x] = min(low[x], low[y]);
      if (low[y] >= dfn[x]) {
        num++;
        int nod = 0;
        vector<int> es;
        while (top && stk[top] != i) {
          int p = e[stk[top]].to;
          if (col[p] != num) col[p] = num, nod++;
          es.push_back(stk[top]);
          top--;
        }
        int p = e[stk[top]].to;
        if (col[p] != num) col[p] = num, nod++;
        es.push_back(stk[top]);
        top--;
        if (col[x] != num) col[x] = num, nod++;
        if (nod == (int)es.size()) {
          ans += nod;
          for (int j = 0; j < (int)es.size(); j++) ok[es[j] / 2 + 1] = true;
        }
      }
    } else if (dfn[y] < dfn[x]) {
      stk[++top] = i;
      low[x] = min(low[x], dfn[y]);
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) head[i] = -1;
  for (int i = 1; i <= m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    addedge(a, b);
    addedge(b, a);
  }
  for (int i = 1; i <= n; i++) {
    if (dfn[i]) continue;
    tarjan(i, 0);
  }
  printf("%d\n", ans);
  for (int i = 1; i <= m; i++)
    if (ok[i]) printf("%d ", i);
  return 0;
}
