#include <bits/stdc++.h>
using namespace std;
long long power(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) {
      res = (res * x) % p;
    }
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long modInverse(long long a, long long p) { return power(a, p - 2, p); }
void gcd(long long a, long long b, long long& d, long long& u, long long& v) {
  if (b == 0) {
    d = a;
    u = 1;
    v = 0;
  } else {
    gcd(b, a % b, d, v, u);
    v -= a / b * u;
  }
}
long long Inverse(long long a, long long m) {
  a %= m;
  if (a < 0) a += m;
  long long d, u, v;
  gcd(a, m, d, u, v);
  assert(d == 1);
  u %= m;
  if (u < 0) u += m;
  return u;
}
long long gcd(long long x, long long y) {
  if (x == 0 || y == 0) {
    return max(y, x);
  }
  return gcd(y % x, x);
}
long long gcdExtended(long long a, long long b, long long& x, long long& y) {
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  long long x1, y1;
  long long gcd = gcdExtended(b % a, a, x1, y1);
  x = y1 - (b / a) * x1;
  y = x1;
  return gcd;
}
vector<long long> adj[10005];
map<pair<long long, long long>, long long> mapedge;
map<long long, pair<long long, long long> > edges;
vector<long long> root;
set<long long> backedge;
long long col[10004], vis[10004];
long long ss;
bool dfs(long long cur, long long c) {
  col[cur] = c;
  bool ok = 1;
  for (auto next : adj[cur]) {
    if (vis[next] == 0) {
      vis[next] = vis[cur] + 1;
      if (!dfs(next, 1 - c)) ok = 0;
    } else if (col[next] == col[cur]) {
      ok = 0;
      ss++;
      backedge.insert(mapedge[{min(cur, next), max(cur, next)}]);
    }
  }
  return ok;
}
long long req = 0;
vector<long long> fans;
long long dp[10004], dp1[10004];
void dfs2(long long cur, long long par) {
  dp[cur] = 0;
  dp1[cur] = 0;
  for (auto next : adj[cur]) {
    if (vis[next] == 0) {
      vis[next] = vis[cur] + 1;
      dfs2(next, cur);
      ;
      dp[cur] += dp[next];
      dp1[cur] += dp1[next];
      continue;
    }
    if (vis[next] < vis[cur]) {
      dp1[cur]++;
      if (col[next] == col[cur]) {
        dp[cur]++;
      }
    }
    if (vis[next] > vis[cur]) {
      dp1[cur]--;
      if (col[next] == col[cur]) {
        dp[cur]--;
      }
    }
  }
  if (cur != root[0]) {
    dp1[cur]--;
    if (dp[cur] == req && dp[cur] == dp1[cur]) {
      fans.push_back(mapedge[{min(cur, par), max(cur, par)}]);
    }
  }
}
int main() {
  long long n, m;
  scanf("%lld %lld", &(n), &(m));
  for (long long i = 0; i < m; i++) {
    long long x, y;
    scanf("%lld %lld", &(x), &(y));
    ;
    adj[x].push_back(y);
    adj[y].push_back(x);
    mapedge[{min(x, y), max(x, y)}] = i + 1;
    edges[i + 1] = {min(x, y), max(x, y)};
  }
  for (long long i = 1; i <= n; i++) {
    if (vis[i]) continue;
    vis[i] = 1;
    if (dfs(i, 0)) continue;
    root.push_back(i);
  }
  if (root.size() != 1) {
    if (root.size() == 0) {
      cout << m << endl;
      for (long long i = 1; i <= m; i++) {
        cout << i << " ";
      }
      cout << endl;
    } else {
      cout << 0 << endl;
    }
    return 0;
  }
  for (long long i = 0; i < 10001; i++) {
    vis[i] = 0;
  };
  if (ss != backedge.size() * 2) cout << "no" << endl;
  if (backedge.size() == 1) {
    for (auto x : backedge) {
      fans.push_back(x);
    }
  }
  vis[root[0]] = 1;
  req = backedge.size();
  dfs2(root[0], 0);
  cout << fans.size() << endl;
  sort(fans.begin(), fans.end());
  for (auto p : fans) {
    cout << p << " ";
  }
}
