#include <bits/stdc++.h>
const int nmax = 10000, mmax = nmax << 1;
int n, m, fst[nmax + 18], pnt[mmax + 18], nxt[mmax + 18], tot = 1;
int d[nmax + 18], eve[nmax + 18], odd[nmax + 18], chosen[nmax + 18];
int oddn, ans, cur[nmax + 18], g[nmax + 18], gg[nmax + 18];
bool ed[mmax + 18];
inline void add(int s, int t) {
  pnt[++tot] = t, nxt[tot] = fst[s], fst[s] = tot;
}
void dfs(int x) {
  for (cur[x] = fst[x]; cur[x]; cur[x] = nxt[cur[x]])
    if (!ed[cur[x]] && d[pnt[cur[x]]] < d[x]) {
      ed[cur[x]] = ed[cur[x] ^ 1] = 1;
      if (d[pnt[cur[x]]])
        if ((d[pnt[cur[x]]] & 1) == (d[x] & 1))
          ++odd[x], --odd[pnt[cur[x]]], ++oddn, ++chosen[cur[x] >> 1];
        else
          ++eve[x], --eve[pnt[cur[x]]];
      else {
        d[pnt[cur[x]]] = d[x] + 1;
        dfs(pnt[cur[x]]);
        g[x] += g[pnt[cur[x]]];
        gg[x] += gg[pnt[cur[x]]];
        chosen[cur[x] >> 1] += g[pnt[cur[x]]];
        if (gg[pnt[cur[x]]] > 0) --chosen[cur[x] >> 1];
      }
    }
  g[x] += odd[x];
  gg[x] += eve[x];
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1, ss, tt; i <= m; ++i)
    scanf("%d%d", &ss, &tt), add(ss, tt), add(tt, ss);
  for (int i = 1; i <= n; ++i)
    if (!d[i]) d[i] = 1, dfs(i);
  for (int i = 1; i <= m; ++i)
    if (chosen[i] == oddn || !oddn) ++ans;
  printf("%d\n", ans);
  for (int i = 1; i <= m; ++i)
    if (chosen[i] == oddn || !oddn) printf("%d ", i);
  return 0;
}
