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 INF = 0x3f3f3f3f;
const int M = 100007;
const int N = 100007;
struct Edge {
  int v, id;
  Edge *nxt;
} nil;
Edge *NIL = &nil;
Edge edge[2 * M];
Edge *head[N], *ecnt;
inline void AddEdge(int u, int v, int id) {
  ecnt->v = v;
  ecnt->id = id;
  ecnt->nxt = head[u];
  head[u] = ecnt++;
  ecnt->v = u;
  ecnt->id = id;
  ecnt->nxt = head[v];
  head[v] = ecnt++;
}
void Init() {
  ecnt = &edge[0];
  for (int i = 0; i < N; i++) head[i] = NIL;
}
int n, m, pcnt;
int dfn[N], cf[N], im[N];
int lik[N], Fa[N];
void Dfs1(int u, int fa) {
  dfn[u] = ++pcnt;
  for (Edge *e = head[u]; e != NIL; e = e->nxt) {
    if (!dfn[e->v]) {
      Dfs1(e->v, u);
      cf[u] += cf[e->v];
    } else if (e->v != fa)
      if (dfn[e->v] < dfn[u]) cf[u]++, cf[e->v]--;
  }
}
vector<int> ans, U, V, ID;
void Dfs2(int u, int fa) {
  Fa[u] = fa;
  im[u] = im[fa] + (cf[u] > 1);
  for (Edge *e = head[u]; e != NIL; e = e->nxt)
    if (e->v != fa) {
      if (!Fa[e->v])
        Dfs2(e->v, u), lik[e->v] = e->id;
      else if (dfn[u] > dfn[e->v]) {
        U.push_back(u);
        V.push_back(e->v);
        ID.push_back(e->id);
      }
    }
}
void Solve(int u, int v, int idx) {
  if (dfn[u] < dfn[v]) swap(u, v);
  int kk = im[u] - im[v];
  if (kk == 0) {
    int pla = u;
    while (pla != v) {
      ans.push_back(lik[pla]);
      pla = Fa[pla];
    }
    ans.push_back(idx);
  }
}
int main() {
  Init();
  scanf("%d %d", &n, &m);
  for (int i = 1, u, v, w; i <= m; i++) {
    scanf("%d %d", &u, &v);
    AddEdge(u, v, i);
  }
  Dfs1(1, 1);
  Dfs2(1, 1);
  for (int i = 0; i < ID.size(); i++) Solve(U[i], V[i], ID[i]);
  sort(ans.begin(), ans.end());
  printf("%d\n", ans.size());
  if (ans.size() != 0) printf("%d", ans[0]);
  for (int i = 1; i < ans.size(); i++) printf(" %d", ans[i]);
  puts("");
  return 0;
}
