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 = 100009;
int ver[N << 1], nxt[N << 1], h[N], tot = -1, col[N], m, tofa[N], n, fa[N],
                                    dep[N], ans[N], cnt;
bool istree[N << 1], vis[N];
vector<int> Tofa;
inline void add(int x, int y) { ver[++tot] = y, nxt[tot] = h[x], h[x] = tot; }
inline void dfs(int u, int f) {
  dep[u] = dep[f] + 1;
  fa[u] = f;
  vis[u] = true;
  for (int i = h[u]; i; i = nxt[i]) {
    int v = ver[i];
    if (!vis[v]) {
      tofa[v] = i;
      istree[i] = true;
      dfs(v, u);
    }
  }
}
inline void Dfs(int u, int fa) {
  vis[u] = true;
  for (int i = h[u]; i; i = nxt[i]) {
    int v = ver[i];
    if (istree[i]) {
      Dfs(v, u);
      col[u] += col[v];
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    add(x, y), add(y, x);
  }
  for (int i = 1; i <= n; i++)
    if (!vis[i]) dfs(i, 0);
  for (int i = 0; i <= tot; i += 2) {
    if (istree[i] || istree[i ^ 1]) continue;
    int u = ver[i ^ 1], v = ver[i];
    if (dep[u] < dep[v]) swap(u, v);
    col[u]++, col[v]--;
    Tofa.push_back(i);
  }
  memset(vis, 0, sizeof vis);
  for (int i = 1; i <= n; i++)
    if (!vis[i]) Dfs(i, 0);
  for (auto i : Tofa) {
    int u = ver[i ^ 1], v = ver[i];
    if (dep[u] < dep[v]) swap(u, v);
    int tmp = u;
    while (tmp != v) {
      if (col[tmp] != 1) goto school;
      tmp = fa[tmp];
    }
    ans[++cnt] = (i + 2) / 2;
    while (u != v) {
      ans[++cnt] = (tofa[u] + 2) / 2;
      u = fa[u];
    }
  school:;
  }
  sort(ans + 1, ans + 1 + cnt);
  printf("%d\n", cnt);
  for (int i = 1; i <= cnt; i++) printf("%d ", ans[i]);
  return 0;
}
