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;
namespace IO {
template <typename T>
inline void read(T &x) {
  int f = 1;
  x = 0;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ 48);
  x *= f;
}
template <typename T>
inline void chkmax(T &x, T y) {
  x = x > y ? x : y;
}
template <typename T>
inline void chkmin(T &x, T y) {
  x = x < y ? x : y;
}
template <typename T>
inline void write(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
template <typename T>
inline void writesp(T x) {
  write(x);
  putchar(' ');
}
template <typename T>
inline void writeln(T x) {
  write(x);
  putchar('\n');
}
}  // namespace IO
using namespace IO;
const int N = 1e5 + 5;
const int M = 2e5 + 5;
int head[N], ver[M], Next[M], tot;
inline void add(int u, int v) {
  ver[++tot] = v;
  Next[tot] = head[u];
  head[u] = tot;
}
bool E[M], vis[N];
vector<int> vec;
int n, m;
namespace graph {
inline void dfs(int x) {
  vis[x] = 1;
  for (int i = head[x]; ~i; i = Next[i]) {
    int v = ver[i];
    if (vis[v]) continue;
    E[i] = E[i ^ 1] = 1;
    dfs(v);
  }
}
}  // namespace graph
int d[N], F[N], fat[N], Fatver[N];
namespace tree {
inline void getdep(int x, int fa) {
  d[x] = d[fa] + 1;
  fat[x] = fa;
  for (int i = head[x]; ~i; i = Next[i]) {
    int v = ver[i];
    if (v == fa || !E[i]) continue;
    Fatver[v] = i;
    getdep(v, x);
  }
}
inline void dfs(int x, int fa) {
  for (int i = head[x]; ~i; i = Next[i]) {
    int v = ver[i];
    if (v == fa || !E[i]) continue;
    dfs(v, x);
    F[x] += F[v];
  }
}
}  // namespace tree
int main() {
  memset(head, -1, sizeof(head));
  tot = -1;
  read(n);
  read(m);
  int u, v;
  for (int i = 1; i <= m; i++) {
    read(u);
    read(v);
    add(u, v);
    add(v, u);
  }
  graph::dfs(1);
  tree::getdep(1, 0);
  for (int i = 0; i <= tot; i += 2)
    if (!E[i]) {
      u = ver[i], v = ver[i ^ 1];
      if (d[u] < d[v]) swap(u, v);
      F[u]++;
      F[v]--;
    }
  tree::dfs(1, 0);
  for (int i = 0; i <= tot; i += 2)
    if (!E[i]) {
      bool flag = 1;
      int u = ver[i], v = ver[i ^ 1];
      if (d[u] < d[v]) swap(u, v);
      int tmp = u;
      while (fat[u] != v) {
        if (F[u] > 1) {
          flag = 0;
          break;
        }
        u = fat[u];
      }
      if (!flag) continue;
      u = tmp;
      vec.push_back(i / 2 + 1);
      while (u != v) {
        vec.push_back(Fatver[u] / 2 + 1);
        u = fat[u];
      }
    }
  writeln(vec.size());
  for (int i = 0; i < vec.size(); i++) writesp(vec[i]);
  puts("");
  return 0;
}
