#include <bits/stdc++.h>
using namespace std;
int o[11111], from[11111], num1[11111], num2[11111], b[11111], aa[11111 * 2][2],
    deep[11111];
int n, m, it, cnt, tot = 1;
bool vt[11111], flag[11111];
void out(int *a, int l, int r) {
  for (int i = l; i <= r; i++) printf("%d ", a[i]);
  printf("\n");
}
void dfs(int v) {
  vt[v] = true;
  for (int p = o[v]; p; p = aa[p][0]) {
    int y = aa[p][1];
    if ((p ^ 1) == from[v]) continue;
    if (!vt[y]) {
      from[y] = p;
      deep[y] = deep[v] + 1;
      dfs(y);
      num1[v] += num1[y];
      num2[v] += num2[y];
    } else if (deep[v] > deep[y]) {
      int t = deep[v] - deep[y];
      if (!(((t)&1) == 1)) {
        it = p;
        cnt++;
        num1[v]++, num1[y]--;
      } else
        num2[v]++, num2[y]--;
    }
  }
}
void addedge(int p, int q) {
  tot++;
  aa[tot][1] = q;
  aa[tot][0] = o[p];
  o[p] = tot;
}
int main() {
  scanf("%d%d", &n, &m);
  int i, x, y;
  for (i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    addedge(x, y), addedge(y, x);
  }
  for (i = 1; i <= n; i++)
    if (!vt[i]) dfs(i);
  if (cnt == 0) {
    printf("%d\n", m);
    for (i = 1; i <= m; i++) printf("%d ", i);
    printf("\n");
  } else if (cnt == 1) {
    int ans = 1;
    flag[it >> 1] = true;
    b[b[0] = 1] = it >> 1;
    for (i = 1; i <= n; i++)
      if (num1[i] == 1 && num2[i] == 0) {
        ans++;
        flag[from[i] >> 1] = true;
        b[++b[0]] = from[i] >> 1;
      }
    printf("%d\n", ans);
    sort(b + 1, b + b[0] + 1);
    for (i = 1; i <= b[0]; i++) printf("%d ", b[i]);
    printf("\n");
  } else {
    int ans = 0;
    for (i = 1; i <= n; i++)
      if (num1[i] == cnt && num2[i] == 0) {
        ans++;
        flag[from[i] >> 1] = true;
        b[++b[0]] = from[i] >> 1;
      }
    printf("%d\n", ans);
    sort(b + 1, b + b[0] + 1);
    for (i = 1; i <= b[0]; i++) printf("%d ", b[i]);
    printf("\n");
  }
  return 0;
}
