#include <bits/stdc++.h>
using namespace std;
int n, m, k, l, i, j, t, a, b, in[100005], col[100005], ch, ct, compct,
    uku[100005][2], res[100005], ans;
vector<pair<pair<int, int>, int> > v[100005];
void dfs1(int x, int par) {
  in[x] = ++t;
  col[x] = 1 ^ col[par];
  for (int i = 0; i < v[x].size(); i++) {
    auto to = v[x][i];
    if (to.first.first == par) {
      v[x][i].first.second = -1;
      continue;
    }
    if (!in[to.first.first]) {
      dfs1(to.first.first, x);
      uku[x][0] += uku[to.first.first][0];
      uku[x][1] += uku[to.first.first][1];
    } else if (in[to.first.first] < in[x]) {
      v[x][i].first.second = 1;
      uku[x][(col[to.first.first] == col[x])]++;
      uku[to.first.first][(col[to.first.first] == col[x])]--;
      if (col[x] == col[to.first.first]) {
        ct++;
        ch = 1;
      }
    } else {
      v[x][i].first.second = -1;
    }
  }
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> a >> b;
    v[a].push_back({{b, 0}, i});
    v[b].push_back({{a, 0}, i});
  }
  for (int i = 1; i <= n; i++) {
    if (in[i] == 0) {
      t = ch = 0;
      dfs1(i, 0);
      compct += ch;
    }
  }
  if (compct > 1) {
    cout << 0;
    return 0;
  }
  if (ct == 0) {
    cout << m << endl;
    for (int i = 1; i <= m; i++) {
      cout << i << " ";
    }
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    for (auto to : v[i]) {
      if (to.first.second == -1) continue;
      if (to.first.second == 1) {
        if (ct == 1 && col[i] == col[to.first.first]) {
          ans += (1 - res[to.second]);
          res[to.second] = 1;
        }
      } else {
        if (uku[to.first.first][0] == 0 && uku[to.first.first][1] == ct) {
          ans += (1 - res[to.second]);
          res[to.second] = 1;
        }
      }
    }
  }
  cout << ans << endl;
  for (int i = 1; i <= m; i++) {
    if (res[i]) cout << i << " ";
  }
}
