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 char gc() {
  static char now[1 << 16], *S, *T;
  if (T == S) {
    T = (S = now) + fread(now, 1, 1 << 16, stdin);
    if (T == S) return EOF;
  }
  return *S++;
}
inline int read() {
  int x = 0, f = 1;
  char ch = gc();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = gc();
  }
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = gc();
  return x * f;
}
const int N = 1e5 + 10;
struct node {
  int y, next, id;
} data[N << 1];
struct node1 {
  int x, y, id;
} q[N];
int top, n, m, num, ans[N], h[N], dfn[N], low[N], size[N], s, b[N];
vector<int> eg[N];
inline void tarjan(int x, int fa) {
  dfn[x] = low[x] = ++num;
  for (int i = h[x]; i; i = data[i].next) {
    int y = data[i].y;
    if (y == fa) continue;
    if (dfn[y] && (dfn[y] < dfn[x])) q[++top] = (node1){x, y, data[i].id};
    if (!dfn[y]) {
      q[++top] = (node1){x, y, data[i].id};
      tarjan(y, x);
      low[x] = min(low[x], low[y]);
      if (low[y] >= dfn[x]) {
        ++s;
        node1 now;
        while (1) {
          now = q[top--];
          eg[s].push_back(now.id);
          if (b[now.x] != s) ++size[s], b[now.x] = s;
          if (b[now.y] != s) ++size[s], b[now.y] = s;
          if (now.x == x && now.y == y) break;
        }
      }
    } else
      low[x] = min(low[x], dfn[y]);
  }
}
int main() {
  n = read();
  m = read();
  for (int i = 1; i <= m; ++i) {
    int x = read(), y = read();
    data[++num].y = y;
    data[num].next = h[x];
    h[x] = num;
    data[num].id = i;
    data[++num].y = x;
    data[num].next = h[y];
    h[y] = num;
    data[num].id = i;
  }
  num = 0;
  for (int i = 1; i <= n; ++i)
    if (!dfn[i]) tarjan(i, i);
  top = 0;
  for (int i = 1; i <= s; ++i)
    if (eg[i].size() == size[i])
      for (int j = 0; j < eg[i].size(); ++j) ans[++top] = eg[i][j];
  sort(ans + 1, ans + top + 1);
  printf("%d\n", top);
  for (int i = 1; i <= top; ++i) printf("%d ", ans[i]);
  return 0;
}
