#include <bits/stdc++.h>
using namespace std;
struct node {
  int e;
  int id;
};
int n, m;
int dfn[100005], low[100005], pcc, cnt;
set<int> p[100005], e[100005], ans;
stack<int> s;
vector<node> g[100005];
void tarjan(int u, int fa) {
  dfn[u] = low[u] = ++cnt;
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i].e;
    if (v != fa) {
      if (dfn[v] == 0) {
        s.push(g[u][i].id);
        s.push(v);
        s.push(u);
        tarjan(v, u);
        low[u] = min(low[u], low[v]);
        if (low[v] >= dfn[u]) {
          int su, sv, sid;
          pcc++;
          do {
            su = s.top();
            s.pop();
            sv = s.top();
            s.pop();
            sid = s.top();
            s.pop();
            p[pcc].insert(su);
            p[pcc].insert(sv);
            e[pcc].insert(sid);
          } while (min(su, sv) != min(u, v) || max(su, sv) != max(u, v));
        }
      } else if (dfn[v] < dfn[u]) {
        s.push(g[u][i].id);
        s.push(v);
        s.push(u);
        low[u] = min(low[u], dfn[v]);
      }
    }
  }
}
int main() {
  cin >> n >> m;
  for (int i = 1, u, v; i <= m; i++) {
    cin >> u >> v;
    g[u].push_back((node){v, i});
    g[v].push_back((node){u, i});
  }
  for (int i = 1; i <= n; i++)
    if (dfn[i] == 0) tarjan(i, 0);
  for (int i = 1; i <= pcc; i++)
    if (p[i].size() == e[i].size())
      for (set<int>::iterator it = e[i].begin(); it != e[i].end(); it++)
        ans.insert((*it));
  cout << ans.size() << '\n';
  for (set<int>::iterator it = ans.begin(); it != ans.end(); it++)
    cout << (*it) << ' ';
  return 0;
}
