#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000001;
int cnt, tot, num = 1;
int e[maxn], o[maxn], p[maxn];
int in[maxn], id[maxn], to[maxn];
int ans[maxn], dep[maxn], from[maxn], head[maxn];
inline void add(int u, int v, int w) {
  from[++num] = head[u];
  to[num] = v;
  id[num] = w;
  head[u] = num;
}
inline void dfs(int now, int fa, int pre) {
  dep[now] = dep[fa] + 1;
  p[now] = id[pre];
  for (register int i = head[now]; i; i = from[i]) {
    if ((i ^ pre) == 1) continue;
    if (!dep[to[i]]) {
      dfs(to[i], now, i);
      in[id[i]] = true;
      e[id[pre]] += e[id[i]], o[id[pre]] += o[id[i]];
    } else {
      if ((i & 1) && to[i] == now) {
        ++cnt;
        ++o[id[i]];
      } else if (dep[now] > dep[to[i]]) {
        if ((dep[now] - dep[to[i]]) & 1) {
          ++e[id[i]], ++e[id[pre]];
          --e[p[to[i]]];
        } else {
          ++cnt, --o[p[to[i]]];
          ++o[id[i]], ++o[id[pre]];
        }
      }
    }
  }
}
int main() {
  register int m, n;
  scanf("%d%d", &n, &m);
  for (register int i = 1; i <= m; ++i) {
    register int u, v;
    scanf("%d%d", &u, &v);
    add(u, v, i);
    add(v, u, i);
  }
  for (register int i = 1; i <= n; ++i)
    if (!dep[i]) dfs(i, 0, 0);
  if (!cnt) {
    for (register int i = 1; i <= m; ++i) ans[++tot] = i;
  } else {
    for (register int i = 1; i <= m; ++i)
      if (in[i]) {
        if (cnt == o[i] && !e[i]) ans[++tot] = i;
      } else if (cnt == 1 && o[i] == 1)
        ans[++tot] = i;
  }
  printf("%d\n", tot);
  for (register int i = 1; i <= tot; ++i) printf("%d ", ans[i]);
  printf("\n");
  return 0;
}
