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;
const int N = 2e5 + 1;
struct List {
  int head[N], tail[N], next[N];
  ;
  void combine(int x, int y) {
    if (head[y]) {
      if (!head[x])
        head[x] = head[y], tail[x] = tail[y];
      else {
        next[tail[x]] = head[y];
        tail[x] = tail[y];
      }
      head[y] = tail[y] = 0;
    }
  }
  void add(int x, int y) {
    if (!head[x])
      head[x] = tail[x] = y;
    else
      next[tail[x]] = y, tail[x] = y;
  }
  void clear(int x) { head[x] = tail[x] = 0; }
};
struct Tarjan {
  vector<pair<int, int>> g[N];
  int n, m, tot;
  bool instack[N];
  List in_edge, stack;
  int dfn[N], low[N];
  vector<int> edge_on_simple_circle, d;
  void read() {
    cin >> n >> m;
    for (int i = 1; i <= m; i++) {
      int x, y;
      cin >> x >> y;
      g[x].push_back((make_pair(y, i)));
      g[y].push_back((make_pair(x, i)));
    }
  }
  void dfs(int x, int lastedge) {
    dfn[x] = low[x] = ++tot;
    instack[x] = 1;
    for (auto y : g[x]) {
      if (y.second == lastedge) continue;
      if (!dfn[y.first]) {
        dfs(y.first, y.second);
        if (dfn[x] < low[y.first]) {
          continue;
        } else {
          in_edge.add(low[y.first], y.second);
        }
        if (low[y.first] == dfn[x]) {
          int calc = 1;
          int sig = dfn[x], p = stack.head[sig];
          while (p) {
            instack[p] = 0;
            ++calc;
            p = stack.next[p];
          }
          stack.clear(sig);
          d.clear();
          instack[x] = 1;
          int e = in_edge.head[sig];
          while (e) d.push_back(e), e = in_edge.next[e];
          in_edge.head[sig] = in_edge.tail[sig] = 0;
          if (d.size() == calc) {
            for (auto e : d) edge_on_simple_circle.push_back(e);
          }
        } else {
          if (low[y.first] < low[x]) {
            in_edge.combine(low[y.first], low[x]);
            stack.combine(low[y.first], low[x]);
          } else if (low[y.first] > low[x]) {
            in_edge.combine(low[x], low[y.first]);
            stack.combine(low[x], low[y.first]);
          }
          low[x] = min(low[x], low[y.first]);
        }
      } else {
        if (instack[y.first]) {
          if (low[x] > dfn[y.first]) {
            in_edge.add(dfn[y.first], y.second);
            in_edge.combine(dfn[y.first], low[x]);
            stack.combine(dfn[y.first], low[x]);
            low[x] = dfn[y.first];
          } else if (low[x] < dfn[y.first]) {
            in_edge.combine(low[x], dfn[y.first]);
            stack.combine(low[x], dfn[y.first]);
          }
        }
      }
    }
    stack.clear(dfn[x]);
    in_edge.clear(dfn[x]);
    if (low[x] != dfn[x])
      stack.add(low[x], x);
    else
      instack[x] = 0;
  }
  void build() {
    for (int i = 1; i <= n; i++)
      if (!dfn[i]) tot = 0, dfs(i, 0);
  }
  void output() {
    sort(edge_on_simple_circle.begin(), edge_on_simple_circle.end());
    cout << edge_on_simple_circle.size() << endl;
    for (auto e : edge_on_simple_circle) cout << e << ' ';
  }
} f;
int main() {
  ios::sync_with_stdio(false);
  f.read();
  f.build();
  f.output();
  return 0;
}
