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;
mt19937 gen(880907);
template <typename T1, typename T2>
ostream& operator<<(ostream& out, const pair<T1, T2>& p) {
  out << p.first << " " << p.second;
  return out;
}
struct BccVertex {
  int n, nScc, step, dfn[200005], low[200005];
  vector<int> E[200005], sccv[200005];
  int top, stk[200005];
  void init(int _n) {
    n = _n;
    nScc = step = 0;
    for (int i = 0; i < n; i++) E[i].clear();
  }
  void addEdge(int u, int v) {
    E[u].push_back(v);
    E[v].push_back(u);
  }
  void DFS(int u, int f) {
    dfn[u] = low[u] = step++;
    stk[top++] = u;
    for (auto v : E[u]) {
      if (v == f) continue;
      if (dfn[v] == -1) {
        DFS(v, u);
        low[u] = min(low[u], low[v]);
        if (low[v] >= dfn[u]) {
          int z;
          sccv[nScc].clear();
          do {
            z = stk[--top];
            sccv[nScc].push_back(z);
          } while (z != v);
          sccv[nScc++].push_back(u);
        }
      } else
        low[u] = min(low[u], dfn[v]);
    }
  }
  vector<vector<int>> solve() {
    vector<vector<int>> res;
    for (int i = 0; i < n; i++) dfn[i] = low[i] = -1;
    for (int i = 0; i < n; i++)
      if (dfn[i] == -1) {
        top = 0;
        DFS(i, i);
      }
    for (int i = 0; i < nScc; i++) res.push_back(sccv[i]);
    return res;
  }
} graph;
int n, m;
vector<set<int>> bln;
vector<vector<int>> bcc, cans;
vector<pair<int, int>> edge;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  bln.resize(n);
  edge.resize(m);
  graph.init(n);
  for (int i = 0, a, b; i < m; i++) {
    cin >> a >> b;
    --a, --b;
    edge[i] = {a, b};
    graph.addEdge(a, b);
  }
  bcc = graph.solve();
  for (int i = 0; i < bcc.size(); i++) {
    for (auto j : bcc[i]) {
      bln[j].insert(i);
    }
  }
  vector<int> num(bcc.size());
  cans.resize(bcc.size());
  for (int i = 0; i < m; i++) {
    if (bln[edge[i].first].size() > bln[edge[i].second].size())
      swap(edge[i].first, edge[i].second);
    for (auto j : bln[edge[i].first]) {
      if (bln[edge[i].second].count(j)) {
        num[j]++;
        cans[j].push_back(i + 1);
        break;
      }
    }
  }
  vector<int> single, ans;
  for (int i = 0; i < bcc.size(); i++) {
    if (bcc[i].size() == num[i]) {
      for (auto j : cans[i]) ans.push_back(j);
    }
  }
  sort(ans.begin(), ans.end());
  cout << ans.size() << '\n';
  for (auto i : ans) cout << i << " ";
  cout << '\n';
  return 0;
}
