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;
const int N = 100005, M = 200005;
int n, m, tot = 0, Next[M], to[M], head[M], pre[N], low[N], tim = 0, rt, num,
          ct = 0, co[N], sz[N], re[N];
bool cut[N];
inline void add(int x, int y) {
  Next[++tot] = head[x];
  to[tot] = y;
  head[x] = tot;
}
struct node {
  int u, v;
} a[M];
set<int> s[N];
inline void dfs(int x, int fa) {
  int i, son = 0;
  pre[x] = low[x] = ++tim;
  for (i = head[x]; i; i = Next[i])
    if (to[i] != fa) {
      if (!pre[to[i]]) {
        son++;
        dfs(to[i], x);
        low[x] = min(low[x], low[to[i]]);
        if (x != rt && low[to[i]] >= pre[x]) cut[x] = 1;
      } else
        low[x] = min(low[x], pre[to[i]]);
    }
  if (x == rt && son >= 2) cut[x] = 1;
}
inline void dfs1(int x) {
  int i;
  co[x] = ct;
  s[ct].insert(x);
  for (i = head[x]; i; i = Next[i]) {
    if (cut[to[i]])
      s[ct].insert(to[i]), co[to[i]] = ct, num++;
    else if (!co[to[i]])
      dfs1(to[i]);
  }
  return;
}
int main() {
  int i, x, y, pp = 0;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    add(x, y);
    add(y, x);
    a[i] = (node){x, y};
  }
  for (i = 1; i <= n; i++)
    if (!pre[i]) {
      rt = i;
      dfs(i, 0);
    }
  for (i = 1; i <= n; i++) {
    if (!co[i] && !cut[i]) {
      ct++;
      dfs1(i);
    }
  }
  for (i = 1; i <= m; i++) {
    if (cut[a[i].u]) swap(a[i].u, a[i].v);
    if (!cut[a[i].u]) sz[co[a[i].u]]++;
  }
  for (i = 1; i <= m; i++) {
    if (!cut[a[i].u])
      if (sz[co[a[i].u]] == s[co[a[i].u]].size()) re[++pp] = i;
  }
  printf("%d\n", pp);
  for (i = 1; i <= pp; i++) printf("%d ", re[i]);
}
