#include <bits/stdc++.h>
using namespace std;
int cnt = 1, N, M, err, t;
int H[102012], B[102012 * 2], Nxt[102012 * 2];
int Used[102012], ans[102012], f[102012], c[102012], d[102012], fa[102012];
inline void Add(int x, int y) {
  Nxt[++cnt] = H[x];
  H[x] = cnt;
  B[cnt] = y;
}
inline void dfs(int x, int k, int last) {
  Used[x] = 1;
  c[x] = k;
  for (int i = H[x]; i; i = Nxt[i])
    if (i != (last ^ 1)) {
      int& y = B[i];
      if (!Used[y]) {
        fa[y] = i;
        dfs(y, 1 - k, i);
        f[x] += f[y];
        d[x] += d[y];
      } else if (Used[y] == 1) {
        if (c[x] == c[y])
          ++cnt, err = i, f[x]++;
        else
          ++d[x];
      } else if (Used[y] == 2)
        if (c[x] == c[y])
          f[x]--;
        else
          d[x]--;
    }
  Used[x] = 2;
}
int main() {
  scanf("%d%d", &N, &M);
  for (int i = 1; i <= M; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    Add(x, y);
    Add(y, x);
  }
  cnt = 0;
  for (int i = 1; i <= N; ++i)
    if (!Used[i]) dfs(i, 0, 0);
  if (!cnt) {
    t = M;
    for (int i = 1; i <= M; ++i) ans[i] = i;
  } else {
    if (cnt == 1 && err) ans[++t] = err >> 1;
    for (int i = 1; i <= N; ++i)
      if (!d[i] && f[i] == cnt) ans[++t] = fa[i] >> 1;
    sort(ans + 1, ans + t + 1);
  }
  cout << t << endl;
  for (int i = 1; i <= t; ++i) printf("%d ", ans[i]);
  return 0;
}
