#include <bits/stdc++.h>
using namespace std;
int n, m, odd, who, a[100010], b[100010], d[100010], f[100010], g[100010],
    h[100010];
vector<int> e[100010], ans;
void dfs(int x, int fa_id) {
  for (int i = 0; i < e[x].size(); i++) {
    int id = e[x][i], v = (a[id] != x) ? a[id] : b[id];
    if (id == fa_id || d[x] < d[v]) continue;
    if (!d[v]) {
      h[v] = id;
      d[v] = d[x] + 1;
      dfs(v, id);
      f[x] += f[v];
      g[x] += g[v];
    } else if ((d[x] - d[v]) & 1) {
      g[x]++;
      g[v]--;
    } else {
      f[x]++;
      f[v]--;
      odd++;
      who = id;
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &a[i], &b[i]);
    e[a[i]].push_back(i);
    e[b[i]].push_back(i);
  }
  for (int i = 1; i <= n; i++)
    if (!d[i]) {
      d[i] = 1;
      dfs(i, 0);
    }
  if (!odd) {
    printf("%d\n", m);
    for (int i = 1; i <= m; i++) printf("%d ", i);
  } else {
    if (odd == 1) ans.push_back(who);
    for (int i = 1; i <= n; i++) {
      if (f[i] == odd && !g[i]) ans.push_back(h[i]);
    }
    sort(ans.begin(), ans.end());
    printf("%d\n", ans.size());
    for (int i = 0; i < ans.size(); i++) printf("%d ", ans[i]);
  }
  return 0;
}
