#include <bits/stdc++.h>
int n, m, head[10010], to[10010 << 1], next[10010 << 1], tot = 0;
inline void $(int u, int v) {
  next[tot] = head[u], to[tot] = v, head[u] = tot++;
  next[tot] = head[v], to[tot] = u, head[v] = tot++;
}
int vis[10010], deep[10010], fa[10010], s0[10010], s1[10010], c0, c1;
std::vector<int> ans;
void dfs(int x) {
  vis[x] = 1;
  for (int i = head[x]; ~i; i = next[i]) {
    if (to[i] == fa[x]) continue;
    if (vis[to[i]]) {
      if (deep[to[i]] < deep[x]) {
        int len = deep[x] - deep[to[i]];
        if (len & 1) {
          c0++;
          s0[to[i]]--;
          s0[x]++;
        } else {
          c1++;
          s1[to[i]]--;
          s1[x]++;
        }
      }
    } else {
      deep[to[i]] = deep[x] + 1;
      fa[to[i]] = x;
      dfs(to[i]);
      s0[x] += s0[to[i]];
      s1[x] += s1[to[i]];
    }
  }
}
void calc(int x) {
  for (int i = head[x]; ~i; i = next[i]) {
    if (to[i] == fa[x]) continue;
    if (fa[to[i]] == x) {
      if (s1[to[i]] == c1 && !s0[to[i]]) ans.push_back(i >> 1);
      calc(to[i]);
    } else if (deep[to[i]] < deep[x]) {
      if (c1 == 1 && !((deep[x] - deep[to[i]]) & 1)) {
        ans.push_back(i >> 1);
      }
    }
  }
}
int main() {
  memset(head, -1, sizeof(head));
  scanf("%d%d", &n, &m);
  for (int i = 1, u, v; i <= m; i++) {
    scanf("%d%d", &u, &v);
    $(u, v);
  }
  for (int i = 1; i <= n; i++)
    if (!vis[i]) dfs(i);
  if (c1) {
    for (int i = 1; i <= n; i++)
      if (!fa[i]) calc(i);
  } else {
    for (int i = 1; i <= m; i++) ans.push_back(i - 1);
  }
  std::sort(ans.begin(), ans.end());
  printf("%lu\n", ans.size());
  for (auto x : ans) printf("%d ", x + 1);
  puts("");
  return 0;
}
