#include <bits/stdc++.h>
const int N = 1e5 + 10;
inline int read() {
  int x = 0;
  char ch = getchar();
  while (!isdigit(ch)) ch = getchar();
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return x;
}
int tot = 1, fir[N], nex[N], got[N], pre[N], a[N], b[N], ans[N], col[N], dep[N],
    lst = 0, cnt = 0;
inline void AddEdge(int u, int v) {
  nex[++tot] = fir[u], fir[u] = tot, got[tot] = v;
  nex[++tot] = fir[v], fir[v] = tot, got[tot] = u;
}
inline void dfs(int u, int fa) {
  col[u] = col[fa] ^ 1, dep[u] = dep[fa] + 1;
  for (int i = fir[u]; i; i = nex[i])
    if (!dep[got[i]]) {
      pre[got[i]] = i / 2, dfs(got[i], u);
      a[u] += a[got[i]], b[u] += b[got[i]];
    } else if (dep[u] > dep[got[i]] + 1) {
      if (col[u] == col[got[i]])
        lst = i / 2, ++cnt, a[u]++, a[got[i]]--;
      else
        b[u]++, b[got[i]]--;
    }
}
int main() {
  int n = read(), m = read(), res = 0;
  for (int i = 1; i <= m; ++i) AddEdge(read(), read());
  dfs(1, 0);
  for (int i = 1; i <= n; ++i)
    if (!dep[i]) dfs(i, 0);
  if (!cnt) {
    printf("%d\n", m);
    for (int i = 1; i <= m; ++i) printf("%d ", i);
    return 0;
  }
  std::cerr << cnt << std::endl;
  if (cnt == 1) ans[lst] = true;
  for (int i = 1; i <= n; ++i)
    if (a[i] == cnt && !b[i]) ans[pre[i]] = true;
  for (int i = 1; i <= m; ++i) res += ans[i];
  printf("%d\n", res);
  for (int i = 1; i <= m; ++i)
    if (ans[i]) printf("%d ", i);
  return 0;
}
