#include <bits/stdc++.h>
using namespace std;
struct edge1 {
  long long to, num;
};
struct edge2 {
  long long v1, v2;
};
vector<edge1> a[100009];
vector<edge2> edges;
vector<long long> res, nums;
set<long long> vertex, point;
stack<long long> s;
long long i, j, k, l, n, m, timer;
long long tin[100009], tmin[100009], vis[100009];
void draw(long long edge) {
  vertex.clear();
  nums.clear();
  while (!s.empty()) {
    vertex.insert(edges[s.top()].v1);
    vertex.insert(edges[s.top()].v2);
    nums.push_back(s.top());
    if (s.top() == edge) {
      s.pop();
      break;
    }
    s.pop();
  }
  if (nums.size() == vertex.size()) {
    for (auto i : nums) res.push_back(i);
  }
}
void dfs(long long v, long long parent) {
  vis[v] = 1;
  tin[v] = tmin[v] = ++timer;
  long long to, edge, child = 0;
  for (auto i : a[v]) {
    to = i.to;
    edge = i.num;
    if (to == parent) continue;
    if (vis[to] == 0) {
      s.push(edge);
      dfs(to, v);
      child++;
      tmin[v] = min(tmin[v], tmin[to]);
      if (tmin[to] >= tin[v]) {
        draw(edge);
      }
    } else {
      tmin[v] = min(tmin[v], tin[to]);
      if (tin[to] < tin[v]) {
        s.push(edge);
      }
    }
  }
}
int main() {
  cin >> n >> m;
  for (i = 1; i <= m; i++) {
    cin >> k >> l;
    a[k].push_back({l, i - 1});
    a[l].push_back({k, i - 1});
    edges.push_back({k, l});
  }
  for (i = 1; i <= n; i++) {
    if (vis[i] == 0) {
      dfs(i, -1);
      draw(-1);
    }
  }
  sort(res.begin(), res.end());
  cout << res.size() << endl;
  for (auto i : res) {
    cout << i + 1 << ' ';
  }
  cout << endl;
  return 0;
}
