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;
inline int read() {
  int x = 0, f = 1, ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
inline void write(int x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10) write(x / 10);
  putchar(x % 10 + '0');
}
inline void writeln(int x) {
  write(x);
  puts("");
}
const int N = 100005, M = 100005;
struct edge {
  int link, next;
} e[M << 1];
int n, m, head[N], tot;
inline void add_edge(int u, int v) {
  e[++tot] = (edge){v, head[u]};
  head[u] = tot;
}
inline void insert(int u, int v) {
  add_edge(u, v);
  add_edge(v, u);
}
inline void init() {
  tot = 1;
  n = read();
  m = read();
  for (int i = 1; i <= m; i++) {
    insert(read(), read());
  }
}
pair<int, int> E[M];
vector<int> vec[N];
vector<int> ans;
bool mark[M << 1], iscut[N];
int belong[M], dfn[N], low[N], cnt, stack[M], top, bcc, ecnt, bl[N], ton[N];
void tarjan(int u, int fa) {
  dfn[u] = low[u] = ++cnt;
  int child = 0;
  for (int i = head[u]; i; i = e[i].next) {
    int v = e[i].link;
    if (!mark[i]) {
      mark[i ^ 1] = mark[i] = 1;
      stack[++top] = i;
      if (!dfn[v]) {
        child++;
        tarjan(v, u);
        low[u] = min(low[u], low[v]);
        if (low[v] >= dfn[u]) {
          bcc++;
          iscut[u] = 1;
          for (;;) {
            int j = stack[top--];
            if (bl[e[j].link] != bcc)
              bl[e[j].link] = bcc, ton[bcc]++,
              E[++ecnt] = make_pair(e[j].link, bcc);
            if (bl[e[j ^ 1].link] != bcc)
              bl[e[j ^ 1].link] = bcc, ton[bcc]++,
                       E[++ecnt] = make_pair(e[j ^ 1].link, bcc);
            belong[(j >> 1)] = bcc;
            if (i == j) break;
          }
        }
      } else {
        low[u] = min(low[u], dfn[v]);
      }
    }
  }
  if (child < 2 && u == fa) iscut[u] = 0;
}
inline void solve() {
  for (int i = 1; i <= n; i++)
    if (!dfn[i]) tarjan(i, i);
  for (int i = 1; i <= m; i++) {
    vec[belong[i]].push_back(i);
  }
  for (int i = 1; i <= bcc; i++) {
    if (vec[i].size() == ton[i]) {
      for (int j = 0; j < vec[i].size(); j++) {
        ans.push_back(vec[i][j]);
      }
    }
  }
  sort(ans.begin(), ans.end());
  writeln(ans.size());
  for (int i = 0; i < ans.size(); i++) write(ans[i]), putchar(' ');
}
int main() {
  init();
  solve();
  return 0;
}
