#include <bits/stdc++.h>
using namespace std;
template <class T>
void in(T &x) {
  x = 0;
  bool f = 0;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = 1;
    c = getchar();
  }
  while ('0' <= c && c <= '9') {
    x = (x << 3) + (x << 1) + (c ^ 48);
    c = getchar();
  }
  if (f) x = -x;
}
void out(int x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) out(x / 10);
  putchar(x % 10 + '0');
}
int n, m;
int v[10010 << 2], u[10010 << 2], nx[10010 << 2], k[10010 << 2];
int cnt = 1, head[10010];
inline void add(int uu, int vv) {
  u[++cnt] = uu, v[cnt] = vv, nx[cnt] = head[uu];
  head[uu] = cnt;
  k[cnt] = (cnt >> 1);
}
int dep[10010];
bool vis[10010];
int tag[10010];
int zt;
vector<int> ans;
int lst;
void dfs(int x, int f, int d) {
  dep[x] = d;
  vis[x] = 1;
  for (register int i = head[x]; i; i = nx[i]) {
    if (i == f) continue;
    if (!vis[v[i]]) {
      dfs(v[i], i ^ 1, d + 1);
    } else {
      if (dep[v[i]] < dep[x]) continue;
      if ((dep[v[i]] - dep[x] + 1) & 1) {
        tag[x]--;
        tag[v[i]]++;
        zt++;
        lst = k[i];
      } else {
        tag[x]++;
        tag[v[i]]--;
      }
    }
  }
}
int dfs2(int x, int f) {
  vis[x] = 1;
  int res = tag[x];
  for (register int i = head[x]; i; i = nx[i]) {
    if (vis[v[i]]) continue;
    res += dfs2(v[i], i);
  }
  if (res == zt) ans.push_back(k[f]);
  return res;
}
signed main() {
  in(n), in(m);
  for (register int i = 1, a, b; i <= m; ++i) {
    in(a), in(b);
    add(a, b);
    add(b, a);
  }
  for (register int i = 1; i <= n; ++i) {
    if (!vis[i]) dfs(i, 0, 0);
  }
  if (zt == 0) {
    printf("%d\n", m);
    for (register int i = 1; i <= m; ++i) printf("%d ", i);
    return 0;
  }
  if (zt == 1) ans.push_back(lst);
  memset((vis), 0, sizeof(vis));
  for (register int i = 1; i <= n; ++i) {
    if (!vis[i]) dfs2(i, 0);
  }
  sort(ans.begin(), ans.end());
  printf("%d\n", ans.size());
  for (register int i = 0; i < ans.size(); ++i) {
    printf("%d ", ans[i]);
  }
  return 0;
}
