2 0
 100000 0
 8 9
1 2
2 3
3 4
4 1
5 6
6 7
7 8
8 5
6 8
 2 1
1 2
 11 9
5 9
8 5
11 3
11 1
3 4
7 11
3 1
11 2
7 2
 7 9
7 3
7 4
1 2
2 3
3 1
3 4
4 5
5 6
6 4
 7 5
5 4
7 3
7 1
6 7
3 1
 7 8
1 2
2 3
3 4
4 1
3 5
5 6
6 7
7 3
 6 9
1 2
2 3
1 4
4 2
5 2
5 3
4 5
6 4
6 5
 7 9
1 2
2 4
4 3
3 1
2 3
4 5
5 6
6 7
7 4
 1 0
 6 7
1 2
2 3
3 1
3 4
4 5
5 6
6 4
 4 5
1 2
2 3
3 4
4 1
1 3
 100000 3
99998 99999
99999 100000
100000 99998

0

 0

 4
1 2 3 4 
 0

 6
3 4 6 7 8 9 
 9
1 2 3 4 5 6 7 8 9 
 3
2 3 5 
 8
1 2 3 4 5 6 7 8 
 0

 4
6 7 8 9 
 0

 6
1 2 3 5 6 7 
 0

 3
1 2 3 

#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;
}
