#include <bits/stdc++.h>
using namespace std;
int n, m;
struct edge {
  int from;
  int to;
  int next;
  int id;
} E[1000005 << 1];
int head[1000005];
int sz = 0;
void add_edge(int u, int v, int i) {
  sz++;
  E[sz].from = u;
  E[sz].to = v;
  E[sz].next = head[u];
  E[sz].id = i;
  head[u] = sz;
}
int deep[1000005];
int odd_ring;
int even_ring;
int odd_cnt[1000005];
int even_cnt[1000005];
int tree_edge[1000005];
int is_on_odd[1000005];
int is_on_even[1000005];
void dfs1(int x, int fa) {
  deep[x] = deep[fa] + 1;
  for (int i = head[x]; i; i = E[i].next) {
    int y = E[i].to;
    if (y != fa) {
      if (!deep[y]) {
        tree_edge[y] = E[i].id;
        dfs1(y, x);
      } else if (deep[y] < deep[x]) {
        if ((deep[x] - deep[y] + 1) % 2 == 1) {
          odd_ring++;
          odd_cnt[x]++;
          odd_cnt[y]--;
          is_on_odd[E[i].id] = 1;
        } else {
          even_ring++;
          even_cnt[x]++;
          even_cnt[y]--;
          is_on_even[E[i].id] = 1;
        }
      }
    }
  }
}
void dfs2(int x, int fa) {
  for (int i = head[x]; i; i = E[i].next) {
    int y = E[i].to;
    if (deep[y] == deep[x] + 1) {
      dfs2(y, x);
      odd_cnt[x] += odd_cnt[y];
      even_cnt[x] += even_cnt[y];
    }
  }
}
vector<int> ans;
int main() {
  int u, v;
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d %d", &u, &v);
    add_edge(u, v, i);
    add_edge(v, u, i);
  }
  for (int i = 1; i <= n; i++) {
    if (!deep[i]) dfs1(i, 0);
  }
  for (int i = 1; i <= n; i++) {
    if (deep[i] == 1) dfs2(i, 0);
  }
  if (!odd_ring) {
    for (int i = 1; i <= m; i++) {
      ans.push_back(i);
    }
  } else {
    for (int i = 1; i <= n; i++) {
      if (odd_cnt[i] == odd_ring && even_cnt[i] == 0) {
        ans.push_back(tree_edge[i]);
      }
    }
    if (odd_ring == 1) {
      for (int i = 1; i <= m; i++) {
        if (is_on_odd[i]) {
          ans.push_back(i);
          break;
        }
      }
    }
  }
  sort(ans.begin(), ans.end());
  printf("%d\n", ans.size());
  for (int i = 0; i < ans.size(); i++) {
    printf("%d ", ans[i]);
  }
}
