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>
const int MAXN = 1e5 + 5;
using namespace std;
set<int> ans, Node[MAXN], Edge[MAXN];
map<pair<int, int>, int> mp;
struct VertexBCC {
  int n, m;
  vector<int> E[MAXN << 1];
  vector<int> bcc[MAXN];
  int dfn[MAXN];
  int bccno[MAXN];
  int tot = 0, bccID = 0;
  bool isCut[MAXN];
  stack<pair<int, int> > s;
  int root;
  void init(int n) {
    this->n = n, m = 0;
    tot = bccID = 0;
    for (int i = 0; i <= n; i++) E[i].clear();
    memset(dfn, 0, sizeof(dfn));
    memset(bccno, 0, sizeof(bccno));
    memset(isCut, false, sizeof(isCut));
  }
  void addEdge(int u, int v) {
    E[u].push_back(v);
    E[v].push_back(u);
  }
  int tarjan(int u, int fa) {
    int lowu = dfn[u] = ++tot;
    int child = 0;
    for (int i = 0; i < E[u].size(); i++) {
      int v = E[u][i];
      if (!dfn[v]) {
        s.push(pair<int, int>(u, v));
        child++;
        int lowv = tarjan(v, u);
        lowu = min(lowu, lowv);
        if (lowv >= dfn[u]) {
          bccID++;
          isCut[u] = true;
          bcc[bccID].clear();
          while (true) {
            pair<int, int> e = s.top();
            s.pop();
            int from = e.first, to = e.second;
            Node[bccID].insert(from);
            Node[bccID].insert(to);
            Edge[bccID].insert(mp[make_pair(max(from, to), min(from, to))]);
            if (bccno[from] != bccID) {
              bccno[from] = bccID;
              bcc[bccID].push_back(from);
            }
            if (bccno[to] != bccID) {
              bccno[to] = bccID;
              bcc[bccID].push_back(to);
            }
            if (from == u && to == v) {
              break;
            }
          }
        }
      } else if (dfn[v] < dfn[u] && v != fa) {
        s.push(pair<int, int>(u, v));
        lowu = min(lowu, dfn[v]);
      }
    }
    if (fa < 0 && child == 1) {
      isCut[u] = false;
    }
    return lowu;
  }
  void findBCC() {
    for (int i = 1; i <= n; i++) {
      if (!dfn[i]) {
        root = i;
        tarjan(i, -1);
      }
    }
  }
};
VertexBCC gao;
int main() {
  int n, m;
  cin >> n >> m;
  gao.init(n);
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    gao.addEdge(u, v);
    mp[make_pair(max(u, v), min(u, v))] = i;
  }
  gao.findBCC();
  for (int i = 1; i <= gao.bccID; i++) {
    if (Edge[i].size() == Node[i].size()) {
      ans.insert(Edge[i].begin(), Edge[i].end());
    }
  }
  cout << ans.size() << endl;
  for (auto i : ans) {
    cout << i << " ";
  }
}
