#include <bits/stdc++.h>
using namespace std;
struct ji {
  int nex, to;
} edge[10001 << 1];
int E, n, m, x, y, sum, ans[10001], bj[10001], head[10001], s[10001];
bool vis[10001];
void add(int x, int y) {
  edge[E].nex = head[x];
  edge[E].to = y;
  head[x] = E++;
}
void dfs(int k, int fa, int sh) {
  vis[k] = 1;
  s[k] = sh;
  for (int i = head[k]; i != -1; i = edge[i].nex)
    if (edge[i].to != fa)
      if (!vis[edge[i].to])
        dfs(edge[i].to, k, sh + 1);
      else {
        if (s[k] < s[edge[i].to]) continue;
        int p = s[k] % 2 - s[edge[i].to] % 2;
        if (!p)
          p = 1;
        else
          p = 10001;
        bj[edge[i].to] -= p;
        bj[k] += p;
        if (p == 1) {
          ans[++ans[0]] = (i >> 1);
        }
      }
}
int dfs2(int k, int fa) {
  if (!vis[k]) return 0;
  vis[k] = 0;
  for (int i = head[k]; i != -1; i = edge[i].nex)
    bj[k] += dfs2(edge[i].to, i >> 1);
  if (bj[k] == sum) ans[++ans[0]] = fa;
  return bj[k];
}
int main() {
  memset(head, -1, sizeof(head));
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    add(x, y);
    add(y, x);
  }
  for (int i = 1; i <= n; i++)
    if (!vis[i]) dfs(i, 0, 0);
  if (!ans[0]) {
    printf("%d\n", m);
    for (int i = 1; i <= m; i++) printf("%d ", i);
    return 0;
  }
  if (ans[0] == 1)
    sum = 1;
  else
    swap(sum, ans[0]);
  for (int i = 1; i <= n; i++) dfs2(i, -1);
  printf("%d\n", ans[0]);
  sort(ans + 1, ans + ans[0] + 1);
  for (int i = 1; i <= ans[0]; i++) printf("%d ", ans[i] + 1);
}
