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>
#pragma GCC optimize("O3")
using namespace std;
struct BccVertex {
  int n, nScc, step, dfn[101010], low[101010];
  vector<int> E[101010], sccv[101010];
  int top, stk[101010];
  void init(int _n) {
    n = _n;
    nScc = step = 0;
    for (int i = 1; i <= n; i++) E[i].clear();
  }
  void add_edge(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);
          nScc++;
        }
      } else {
        low[u] = min(low[u], dfn[v]);
      }
    }
  }
  vector<vector<int>> solve() {
    vector<vector<int>> res;
    for (int i = 1; i <= n; i++) {
      dfn[i] = low[i] = -1;
    }
    for (int i = 1; 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;
map<pair<int, int>, int> id;
unordered_set<int> S[101010];
bool on[101010];
void solve() {
  vector<vector<int>> ret = graph.solve();
  for (auto&& i : ret) {
    int sz = i.size();
    vector<int> eid;
    if ((long long)sz * sz < 101010) {
      for (size_t j = 0; j < i.size(); j++)
        for (size_t k = j + 1; k < i.size(); k++)
          if (S[i[j]].find(i[k]) != S[i[j]].end())
            eid.push_back(id[{i[j], i[k]}]);
    } else {
      unordered_set<int> cur;
      for (auto ii : i) cur.insert(ii);
      for (auto ii : i) {
        for (auto j : S[ii])
          if (cur.find(j) != cur.end()) eid.push_back(id[{ii, j}]);
      }
      sort(eid.begin(), eid.end());
      eid.resize(unique(eid.begin(), eid.end()) - eid.begin());
    }
    if (eid.size() == i.size()) {
      for (auto j : eid) on[j] = true;
    }
  }
  vector<int> ans;
  for (int i = 1; i <= m; i++)
    if (on[i]) ans.push_back(i);
  printf("%d\n", (int)ans.size());
  for (auto x : ans) printf("%d ", x);
  puts("");
}
int main() {
  scanf("%d%d", &n, &m);
  graph.init(n);
  for (int i = 1; i <= m; i++) {
    int ui, vi;
    scanf("%d%d", &ui, &vi);
    graph.add_edge(ui, vi);
    S[ui].insert(vi);
    S[vi].insert(ui);
    id[{ui, vi}] = id[{vi, ui}] = i;
  }
  solve();
}
