#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0;
  int w = 0;
  char ch = 0;
  while (ch < '0' || ch > '9') w |= ch == '-', ch = getchar();
  while (ch >= '0' && ch <= '9')
    x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
  return w ? -x : x;
}
const int maxn = 10005;
int hed[maxn], nedge, vis[maxn], fg[maxn][3], n, m, ans, backedge, dep[maxn],
    fa[maxn], odd;
vector<int> son[maxn], rot, Ans;
map<int, int> mat[maxn];
struct node {
  int odd, eve;
};
struct Edge {
  int todot, nex;
} edge[maxn << 1];
void addedge(int a, int b) {
  edge[nedge].todot = b;
  edge[nedge].nex = hed[a];
  hed[a] = nedge++;
}
void dfs(int k, int la) {
  vis[k] = 1;
  for (int i = hed[k]; ~i; i = edge[i].nex) {
    if ((la != -1) && (i == (la ^ 1))) continue;
    int v = edge[i].todot;
    if (vis[v]) {
      if (dep[v] >= dep[k]) continue;
      int t = ((dep[k] - dep[v] + 1) & 1);
      fg[k][t]++;
      fg[v][t]--;
      if (t) {
        backedge = mat[k][v];
        odd++;
      }
      continue;
    }
    dep[v] = dep[k] + 1;
    fa[v] = k;
    son[k].push_back(v);
    dfs(v, i);
  }
}
node operator+(node a, node b) {
  node c;
  c.odd = a.odd + b.odd;
  c.eve = a.eve + b.eve;
  return c;
}
node calc(int k) {
  int t = son[k].size();
  node ret;
  ret.odd = fg[k][1];
  ret.eve = fg[k][0];
  for (int i = 0; i <= t - 1; i++) {
    int v = son[k][i];
    ret = ret + calc(v);
  }
  if ((ret.odd == odd) && (!ret.eve)) {
    ans++;
    Ans.push_back(mat[k][fa[k]]);
  }
  return ret;
}
int main() {
  n = read();
  m = read();
  nedge = 0;
  memset(hed, -1, sizeof(hed));
  for (int i = 1; i <= m; i++) {
    int u, v;
    u = read();
    v = read();
    addedge(u, v);
    addedge(v, u);
    mat[u][v] = mat[v][u] = i;
  }
  for (int i = 1; i <= n; i++)
    if (!vis[i]) {
      dfs(i, -1);
      rot.push_back(i);
    }
  for (int i = 0; i <= rot.size() - 1; i++) node t = calc(rot[i]);
  if (!odd) {
    ans = m;
    Ans.clear();
    for (int i = 1; i <= m; i++) Ans.push_back(i);
  }
  if (odd == 1) {
    ans++;
    Ans.push_back(backedge);
  }
  if (ans) sort(Ans.begin(), Ans.end());
  printf("%d\n", ans);
  for (int i = 0; i <= ans - 1; i++) printf("%d ", Ans[i]);
  printf("\n");
  return 0;
}
