#include <bits/stdc++.h>
int head[10005], n, m, tot, ans, g[10005], f[10005], num, deep[10005];
bool can[20005];
struct node {
  int to, next;
} e[20005];
void dfs(int u, int fa) {
  bool b = 0;
  for (int i = head[u]; i; i = e[i].next) {
    int v = e[i].to;
    if (v == fa && !b) {
      b = 1;
      continue;
    }
    if (!deep[v]) {
      deep[v] = deep[u] + 1;
      dfs(v, u);
      g[u] += g[v], f[u] += f[v];
    } else {
      if (deep[v] < deep[u]) {
        if ((deep[u] - deep[v]) & 1)
          g[u]++;
        else
          tot++, f[u]++;
      } else if ((deep[v] - deep[u]) & 1)
        g[u]--;
      else
        f[u]--;
    }
  }
}
void add(int u, int v) {
  e[++num] = (node){v, head[u]}, head[u] = num;
  e[++num] = (node){u, head[v]}, head[v] = num;
}
void dfs1(int u, int fa) {
  bool b = 0;
  for (int i = head[u]; i; i = e[i].next) {
    int v = e[i].to;
    if (v == fa && !b) {
      b = 1;
      continue;
    }
    if (deep[v] == deep[u] + 1) {
      dfs1(v, u);
      if (f[v] == tot && !g[v] && !can[i + 1 >> 1]) ans++, can[i + 1 >> 1] = 1;
    } else if (tot == 1 && !can[i + 1 >> 1] && deep[u] > deep[v] &&
               !((deep[u] - deep[v]) & 1))
      ans++, can[i + 1 >> 1] = 1;
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    add(u, v);
  }
  for (int i = 1; i <= n; i++)
    if (!deep[i]) deep[i] = 1, dfs(i, 0);
  for (int i = 1; i <= n; i++)
    if (deep[i] == 1) dfs1(i, 0);
  if (!tot) ans = m;
  printf("%d\n", ans);
  for (int i = 1; i <= m; i++)
    if (can[i] || !tot) printf("%d ", i);
}
