#include <bits/stdc++.h>
const int N = 10001;
bool f[N];
int i, j, n, m, t = 1, c[N], d[N], s0[N], s1[N];
int fa[N], en[N + N], nxt[N + N];
void dfs(int u, int p) {
  for (int i = fa[u], v; i; i = nxt[i])
    if (!d[v = en[i]])
      d[v] = d[u] + 1, dfs(v, i >> 1);
    else if (d[v] < d[u] && i >> 1 ^ p)
      if (d[u] + d[v] & 1)
        --s0[v], ++s0[u];
      else
        ++t, ++c[i >> 1], --s1[v], ++s1[u];
}
void cal(int u, int p) {
  d[u] = 1;
  for (int i = fa[u], v; i; i = nxt[i])
    if (!d[v = en[i]]) cal(v, i >> 1), s0[u] += s0[v], s1[u] += s1[v];
  f[p] = s1[u] == t && !s0[u];
}
int main() {
  for (scanf("%d%d", &n, &m); ++t <= m + m;) {
    scanf("%d%d", &i, &j);
    en[t] = j, nxt[t] = fa[i], fa[i] = t;
    en[++t] = i, nxt[t] = fa[j], fa[j] = t;
  }
  for (t = i = 0; i++ < n;)
    if (!d[i]) d[i] = 1, dfs(i, 0);
  if (!t)
    for (printf("%d\n", m), i = 0; i++ < m; printf("%d ", i))
      ;
  else {
    memset(d + 1, 0, 4 * n);
    for (i = 0; i++ < n;)
      if (!d[i]) cal(i, 0);
    for (n = i = 0; i++ < m; n += f[i] |= c[i] == t)
      ;
    for (printf("%d\n", n), i = 0; i++ < m;)
      if (f[i]) printf("%d ", i);
  }
}
