#include <bits/stdc++.h>
int n, m, i, x, y, dep[10010], g[10010], v[10010 << 1], w[10010 << 1],
    nxt[10010 << 1], ed, d[10010], dfn, f[10010], cnt;
int tag0[10010], tag1[10010], h0[10010], h1[10010], ans, q[10010];
inline void read(int& a) {
  char c;
  while (!(((c = getchar()) >= '0') && (c <= '9')))
    ;
  a = c - '0';
  while (((c = getchar()) >= '0') && (c <= '9')) (a *= 10) += c - '0';
}
inline void add(int x, int y, int z) {
  v[++ed] = y;
  w[ed] = z;
  nxt[ed] = g[x];
  g[x] = ed;
}
void dfs(int x) {
  d[x] = ++dfn;
  for (int i = g[x]; i; i = nxt[i])
    if (w[i] != f[x]) {
      int y = v[i];
      if (d[y] && d[y] <= d[x]) {
        if (dep[x] ^ dep[y]) {
          tag0[y]--;
          tag0[x]++;
          h0[w[i]] = 1;
        } else {
          cnt++;
          tag1[y]--;
          tag1[x]++;
          h1[w[i]] = 1;
        }
      } else if (!d[y])
        f[y] = w[i], dep[y] = dep[x] ^ 1, dfs(y);
    }
}
void cal(int x) {
  for (int i = g[x]; i; i = nxt[i])
    if (f[v[i]] == w[i] && d[v[i]] > d[x])
      cal(v[i]), tag0[x] += tag0[v[i]], tag1[x] += tag1[v[i]];
  h0[f[x]] = tag0[x], h1[f[x]] = tag1[x];
}
int main() {
  read(n), read(m);
  for (i = 1; i <= m; i++) read(x), read(y), add(x, y, i), add(y, x, i);
  for (i = 1; i <= n; i++)
    if (!d[i]) dfs(i), cal(i);
  if (!cnt) {
    for (printf("%d\n", m), i = 1; i <= m; i++)
      printf("%d%c", i, i < m ? ' ' : '\n');
    return 0;
  }
  for (i = 1; i <= m; i++)
    if (h1[i] == cnt && !h0[i]) q[++ans] = i;
  for (printf("%d\n", ans), i = 1; i <= ans; i++)
    printf("%d%c", q[i], i < ans ? ' ' : '\n');
  return 0;
}
