#include <bits/stdc++.h>
using namespace std;
const int Maxx = 1000001, Maxn = 2001, INF = 0x3f3f3f3f, Mod = 1e9 + 7;
inline int read() {
  int res = 0, bj = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') bj |= (ch == '-'), ch = getchar();
  while (ch >= '0' && ch <= '9')
    res = (res << 3) + (res << 1) + (ch ^ 48), ch = getchar();
  return bj ? -res : res;
}
void print(int x) {
  if (x > 9) print(x / 10);
  putchar(x % 10 ^ 48);
}
inline void printnum(int x, char ch) {
  if (x < 0) putchar('-'), x = -x;
  print(x), putchar(ch);
}
int n, m, h[Maxx], to[Maxx << 1], nx[Maxx << 1];
char v[Maxx];
int Nr, ps, d[Maxx], P[Maxx], fr[Maxx], p[Maxx], D[Maxx], sz[Maxx];
int gf(const int x) { return p[x] == x ? x : p[x] = gf(p[x]); }
inline void Merge(int x, int y) {
  D[x = gf(x)] = D[y = gf(y)];
  if (sz[x] < sz[y])
    sz[p[x] = y] += sz[x];
  else
    sz[p[y] = x] += sz[y];
}
void Tarjan(int x) {
  v[x] = 1;
  for (int i = h[x], y; i; i = nx[i])
    if (!v[y = to[i]]) {
      d[y] = d[x] + 1, fr[i >> 1] = y;
      Tarjan(y), Merge(y, x);
    }
  for (int i = h[x], y, o, r; i; i = nx[i])
    if (!fr[i >> 1]) {
      y = to[i], fr[i >> 1] = -1, o = d[x] + d[y] - (d[r = D[gf(y)]] << 1) & 1;
      if (o)
        --P[x], --P[y], P[r] += 2;
      else
        ++P[x], ++P[y], P[r] -= 2, ++Nr, ps = i >> 1;
    }
}
void Up(int x) {
  v[x] = 0;
  for (int i = h[x], y; i; i = nx[i])
    if (v[y = to[i]]) Up(y), P[x] += P[y];
}
int main() {
  n = read(), m = read();
  for (int i = 1; i <= n; ++i) sz[p[i] = D[i] = i] = 1;
  for (int i = 1, x, y; i <= m; ++i) {
    nx[i << 1] = h[x = read()], to[h[x] = i << 1] = y = read();
    nx[i << 1 | 1] = h[y], to[h[y] = i << 1 | 1] = x;
  }
  for (int i = n; i; --i)
    if (!v[i]) Tarjan(i);
  if (!Nr) {
    printnum(m, '\n');
    for (int i = 1; i <= m; ++i) printnum(i, ' ');
  } else {
    for (ps = Nr == 1 ? ps : 0; n; --n)
      if (v[n]) Up(n);
    for (int i = 1; i <= m; ++i)
      if (~fr[i] && P[fr[i]] == Nr || i == ps) D[++n] = i;
    printnum(n, '\n');
    for (int i = 1; i <= n; ++i) printnum(D[i], ' ');
  }
  return 0;
}
