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 long long read() {
  long long f = 1, x = 0;
  char s = getchar();
  while (s < '0' || s > '9') {
    if (s == '-') f = -1;
    s = getchar();
  }
  while (s >= '0' && s <= '9') {
    x = x * 10 + (s - '0');
    s = getchar();
  }
  return x * f;
}
const int jzm = 1000000007;
int n, m, i, j, s, o, k;
struct ed {
  int u, v;
  ed() { u = v = 0; }
  ed(int U, int V) {
    u = U;
    v = V;
  }
} e[100005];
vector<int> g[100005];
int v[100005], cnt, d[100005];
int c[100005], f[100005];
long long sum[100005];
int fa[100005], sm[100005];
int findf(int x) { return x == fa[x] ? x : (fa[x] = findf(fa[x])); }
void unionSet(int a, int b) {
  int u = findf(a), v = findf(b);
  sm[v] += sm[u];
  fa[u] = v;
}
void dfs(int x, int fa) {
  v[x] = 1;
  d[x] = d[fa] + 1;
  f[x] = fa;
  for (int i = 0; i < g[x].size(); i++) {
    if (!v[g[x][i]]) {
      dfs(g[x][i], x);
      c[x] += c[g[x][i]];
    } else if (g[x][i] != fa && d[g[x][i]] < d[x]) {
      c[g[x][i]]--;
      c[x]++;
      sm[x]++;
    }
  }
  if (c[x]) unionSet(x, fa);
}
int pr[100005], cn;
int main() {
  n = read();
  m = read();
  for (int i = 1; i <= n; i++) fa[i] = i;
  for (int i = 1; i <= m; i++) {
    s = read();
    o = read();
    g[s].push_back(o);
    g[o].push_back(s);
    e[i] = ed(s, o);
  }
  dfs(1, 0);
  for (int i = 1; i <= m; i++) {
    s = e[i].u;
    o = e[i].v;
    if (d[s] < d[o]) swap(s, o);
    if (findf(s) == findf(o) && sm[findf(s)] == 1) {
      pr[++cn] = i;
    }
  }
  printf("%d\n", cn);
  for (int i = 1; i <= cn; i++) {
    printf("%d ", pr[i]);
  }
  putchar('\n');
  return 0;
}
