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;
struct edge {
  int to, next;
  edge() {}
  edge(int to, int next) {
    this->to = to;
    this->next = next;
  }
} ed[200005];
vector<int> vt[100005];
int head[100005], lnum, esum, Index, top, bccnum;
int dfn[100005], low[100005], mark[200005], bj[100005], st[200005],
    belong[200005], isCut[100005], num[100005];
pair<int, int> E[200005];
void addline(int from, int to) {
  ed[lnum] = edge(to, head[from]);
  head[from] = lnum++;
}
void tarjan(int root, int fa) {
  dfn[root] = low[root] = ++Index;
  int child = 0;
  for (int i = head[root]; ~i; i = ed[i].next) {
    int v = ed[i].to;
    if (mark[i]) continue;
    mark[i] = mark[i ^ 1] = 1;
    st[++top] = i;
    if (!dfn[v]) {
      child++;
      tarjan(v, root);
      low[root] = min(low[root], low[v]);
      if (dfn[root] <= low[v]) {
        isCut[root] = 1;
        bccnum++;
        for (;;) {
          int j = st[top--];
          if (bj[ed[j].to] != bccnum) {
            bj[ed[j].to] = bccnum;
            num[bccnum]++;
            E[++esum] = make_pair(ed[j].to, bccnum);
          }
          if (bj[ed[j ^ 1].to] != bccnum) {
            bj[ed[j ^ 1].to] = bccnum;
            num[bccnum]++;
            E[++esum] = make_pair(ed[j ^ 1].to, bccnum);
          }
          belong[(j >> 1) + 1] = bccnum;
          if (i == j) break;
        }
      }
    } else
      low[root] = min(low[root], dfn[v]);
  }
  if (root == fa && child < 2) isCut[root] = 0;
}
void init() {
  memset(head, -1, sizeof(head));
  memset(dfn, 0, sizeof(dfn));
  memset(low, 0, sizeof(low));
  memset(mark, 0, sizeof(mark));
  memset(belong, 0, sizeof(belong));
  memset(isCut, 0, sizeof(isCut));
  top = 0;
  lnum = 0;
  Index = 0;
  bccnum = 0;
  esum = 0;
}
vector<int> ans;
int main() {
  init();
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    addline(u, v);
    addline(v, u);
  }
  for (int i = 1; i <= n; i++)
    if (!dfn[i]) tarjan(i, i);
  for (int i = 1; i <= m; i++) vt[belong[i]].push_back(i);
  for (int i = 1; i <= bccnum; i++)
    if (vt[i].size() == num[i])
      for (int j = 0; j < vt[i].size(); j++) ans.push_back(vt[i][j]);
  sort(ans.begin(), ans.end());
  printf("%d\n", ans.size());
  for (int i = 0; i < ans.size(); i++) printf("%d ", ans[i]);
  printf("\n");
}
