#include <bits/stdc++.h>
using namespace std;
int fa[10010], c1[10010], c0[10010], dep[10010], s0[10010], s1[10010];
int from[10010], b0[10010], b1[10010], n, m, m1, m0;
vector<pair<int, int> > to[10010];
vector<int> ans;
void init() {
  int i, u, v;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= m; i++) {
    scanf("%d%d", &u, &v);
    to[u].push_back(make_pair(v, i));
    to[v].push_back(make_pair(u, i));
  }
}
void dfs1(int u) {
  int i, v;
  for (i = 0; i < to[u].size(); i++)
    if ((v = to[u][i].first) != fa[u]) {
      if (!dep[v]) {
        dep[v] = dep[u] + 1;
        fa[v] = u;
        from[v] = to[u][i].second;
        dfs1(v);
        s0[u] += s0[v];
        s1[u] += s1[v];
      } else if (dep[v] < dep[u]) {
        if (dep[v] - dep[u] & 1) {
          m0++;
          c0[u]++;
          c0[v]--;
          b0[to[u][i].second] = 1;
        } else {
          m1++;
          c1[u]++;
          c1[v]--;
          b1[to[u][i].second] = 1;
        }
      }
    }
  s0[u] += c0[u];
  s1[u] += c1[u];
}
int solve() {
  int i, ret = 0;
  if (!m1) {
    for (i = 1; i <= m; i++) ans.push_back(i);
    return m;
  }
  for (i = 1; i <= n; i++)
    if (s1[i] == m1 && !s0[i]) {
      ret++;
      ans.push_back(from[i]);
    }
  if (m1 == 1) {
    ret++;
    for (i = 1; i <= m; i++)
      if (b1[i]) {
        ans.push_back(i);
        break;
      }
  }
  return ret;
}
int main() {
  int i;
  init();
  for (i = 1; i <= n; i++)
    if (!dep[i]) {
      dep[i] = 1;
      dfs1(i);
    }
  printf("%d\n", solve());
  sort(ans.begin(), ans.end());
  for (i = 0; i < ans.size(); i++)
    printf("%d%c", ans[i], i == ans.size() - 1 ? '\n' : ' ');
}
