#include <bits/stdc++.h>
using namespace std;
int n, m, p, bck, ans, col[10005], dep[10005], fa[10005], ff[10005],
    cnt1[10005], cnt2[10005];
vector<pair<int, int> > g[10005];
void dfs(int x, int c) {
  col[x] = c;
  for (int i = 0; i < g[x].size(); i++) {
    if (!col[g[x][i].first]) {
      dep[g[x][i].first] = dep[x] + 1;
      fa[g[x][i].first] = g[x][i].second;
      dfs(g[x][i].first, -c);
      cnt1[x] += cnt1[g[x][i].first];
      cnt2[x] += cnt2[g[x][i].first];
    } else if (dep[g[x][i].first] + 1 < dep[x]) {
      if (col[g[x][i].first] == c) {
        p++;
        bck = g[x][i].second;
        cnt1[x]++;
        cnt1[g[x][i].first]--;
      } else {
        cnt2[x]++;
        cnt2[g[x][i].first]--;
      }
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    g[u].push_back(make_pair(v, i));
    g[v].push_back(make_pair(u, i));
  }
  for (int i = 1; i <= n; i++)
    if (!col[i]) dfs(i, 1);
  if (!p) {
    printf("%d\n", m);
    for (int i = 1; i <= m; i++) printf("%d ", i);
    return 0;
  }
  if (p == 1) ff[bck] = 1;
  for (int i = 1; i <= n; i++)
    if (cnt1[i] == p && !cnt2[i]) ff[fa[i]] = true;
  for (int i = 1; i <= m; i++)
    if (ff[i]) ans++;
  printf("%d\n", ans);
  for (int i = 1; i <= m; i++)
    if (ff[i]) printf("%d ", i);
  return 0;
}
