#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int inf_ = 0x7fffffff;
const long long inff = 4557430888798830399ll;
const double pi = acos(-1.0);
long long mod = 1e9 + 7;
map<int, int> id[100005];
struct DCC {
  DCC() { init(0, 0); }
  int n, t, h, m, dfn[100005], low[100005], s[100005], e[100005], g[100005];
  vector<int>*N, cut, D[100005], F[100005];
  bool mark[100005];
  void init(int _n, vector<int>* _N) {
    n = _n;
    N = _N;
    t = h = -1;
    m = 0;
    memset(dfn, 0, sizeof(dfn));
    memset(low, 0, sizeof(low));
    memset(mark, 0, sizeof(mark));
    cut.clear();
  }
  void dfs(int u, int d, int p) {
    int sec = 0, son = d > 1, e;
    dfn[u] = low[u] = d;
    s[++t] = u;
    for (auto v : N[u]) {
      if (!mark[e = id[u][v]]) g[++h] = e, mark[e] = 1;
      if (!dfn[v]) {
        dfs(v, d + 1, u);
        low[u] = min(low[u], low[v]);
        if (low[v] >= dfn[u]) {
          if (++son == 2) cut.push_back(u);
          m += 1;
          D[m].clear();
          D[m].push_back(u);
          F[m].clear();
          do F[m].push_back(g[h]);
          while (g[h--] != e);
          do D[m].push_back(s[t]);
          while (s[t--] != v);
        }
      } else if (v != p || sec++)
        low[u] = min(low[u], dfn[v]);
    }
  }
  void run() {
    for (int i = (1); i <= (n); ++i)
      if (!dfn[i]) dfs(i, 1, 0);
    gen();
  }
  void gen() {
    vector<int> z;
    for (int i = (1); i <= (m); ++i)
      if (((int)F[i].size()) == ((int)D[i].size()) && ((int)D[i].size()) > 2)
        for (auto e : F[i]) z.push_back(e);
    sort((z).begin(), (z).end());
    z.erase(unique((z).begin(), (z).end()), z.end());
    cout << ((int)z.size()) << endl;
    for (int i = (0); i < (((int)z.size())); ++i)
      cout << z[i] << " \n"[i == ((int)z.size()) - 1];
  }
};
vector<int> N[100005];
DCC t;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m, u, v;
  cin >> n >> m;
  for (int i = (1); i <= (m); ++i) {
    cin >> u >> v;
    N[u].push_back(v);
    N[v].push_back(u);
    id[u][v] = id[v][u] = i;
  }
  t.init(n, N);
  t.run();
}
