#include <bits/stdc++.h>
using namespace std;
vector<int> oddedge;
vector<int> res;
int pedge[10005];
int last[10005];
int pre[20005];
int dr[10005];
int in[10005];
int oc[10005];
int ec[10005];
int h[10005];
int e[20005];
int n, m, mc;
void dfs(int x, int par, int dep) {
  int i;
  h[x] = 1;
  in[x] = 1;
  dr[x] = dep;
  for (i = last[x]; i != 0; i = pre[i])
    if (e[i] != par)
      if (h[e[i]] == 0) {
        pedge[e[i]] = ((i + 1) >> 1);
        dfs(e[i], x, dep + 1);
      } else if (in[e[i]])
        if (abs(dr[e[i]] - dr[x]) % 2 == 0) {
          oddedge.push_back(((i + 1) >> 1));
          --oc[e[i]];
          ++oc[x];
        } else
          --ec[e[i]], ++ec[x];
  in[x] = 0;
}
void census(int x) {
  int i;
  for (i = last[x]; i != 0; i = pre[i])
    if (dr[e[i]] == dr[x] + 1) {
      census(e[i]);
      ec[x] += ec[e[i]];
      oc[x] += oc[e[i]];
    }
  if (dr[x] && oc[x] == oddedge.size() && ec[x] == 0) res.push_back(pedge[x]);
}
void work() {
  int i;
  for (i = 1; i <= n; ++i)
    if (h[i] == 0) dfs(i, 0, 0);
  if (oddedge.size() == 0) {
    for (i = 1; i <= m; ++i) res.push_back(i);
    return;
  }
  if (oddedge.size() == 1) res = oddedge;
  for (i = 1; i <= n; ++i)
    if (dr[i] == 0) census(i);
  sort(res.begin(), res.end());
}
int main() {
  int i, x, y;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= m; ++i) {
    scanf("%d%d", &x, &y);
    (e[++mc] = y, pre[mc] = last[x], last[x] = mc),
        (e[++mc] = x, pre[mc] = last[y], last[y] = mc);
  }
  work();
  printf("%d\n", res.size());
  for (i = 0; i < res.size(); ++i)
    if (i == res.size() - 1)
      printf("%d\n", res[i]);
    else
      printf("%d ", res[i]);
  fclose(stdin);
  fclose(stdout);
  return 0;
}
