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 inf = 0x3f3f3f3f;
const long long inff = 4557430888798830399ll;
const double pi = acos(-1.0);
long long mod = 1e9 + 7;
map<int, map<int, int> > eid;
struct SCC_u {
  SCC_u() { init(0); }
  const static int maxn = 100005;
  int n, m, t, dfn[maxn], low[maxn], fa[maxn], s[maxn];
  vector<int> N[maxn], G[maxn];
  void init(int _n) {
    n = _n;
    m = 0;
    t = -1;
    memset(dfn, 0, sizeof(dfn));
    memset(low, 0, sizeof(low));
    for (int i = (1); i <= (n); ++i) fa[i] = i, N[i].clear(), G[i].clear();
  }
  void build(int u, int v) {
    N[u].push_back(v);
    N[v].push_back(u);
  }
  void dfs(int u, int d, int p) {
    int sec = 0, son = d > 1;
    dfn[u] = low[u] = d;
    s[++t] = u;
    for (auto v : N[u]) {
      if (!dfn[v]) {
        dfs(v, d + 1, u);
        low[u] = min(low[u], low[v]);
      } else if (v != p || sec++)
        low[u] = min(low[u], dfn[v]);
    }
    if (dfn[u] == low[u]) do {
        fa[s[t]] = u;
      } while (s[t--] != u);
  }
  void run() {
    for (int i = (1); i <= (n); ++i)
      if (!dfn[i]) dfs(i, 1, 0);
  }
  int rebuild() {
    for (int i = (1); i <= (n); ++i)
      if (fa[i] == i) s[i] = ++m;
    for (int i = (1); i <= (n); ++i)
      for (auto j : N[i])
        if (fa[i] != fa[j]) G[s[fa[i]]].push_back(s[fa[j]]);
    return m;
  }
  int E[maxn], A[maxn];
  vector<int> ans;
  void excu() {
    memset(E, 0, sizeof(E));
    memset(A, 0, sizeof(A));
    ans.clear();
    for (int i = (1); i <= (n); ++i) {
      A[fa[i]] += 1;
      for (auto j : N[i])
        if (fa[i] == fa[j]) E[fa[i]] += 1;
    }
    for (int i = (1); i <= (n); ++i)
      for (auto j : N[i])
        if (fa[i] == fa[j] && A[fa[i]] * 2 == E[fa[i]])
          ans.push_back(eid[i][j]);
    sort((ans).begin(), (ans).end());
    ans.erase(unique((ans).begin(), (ans).end()), ans.end());
    cout << ((int)ans.size()) << endl;
    for (int i = (0); i < (((int)ans.size())); ++i)
      cout << ans[i] << " \n"[i == ((int)ans.size()) - 1];
  }
};
SCC_u s;
int main() {
  int n, m, u, v;
  cin >> n >> m;
  s.init(n);
  for (int i = (1); i <= (m); ++i) {
    cin >> u >> v;
    s.build(u, v);
    eid[u][v] = eid[v][u] = i;
  }
  s.run();
  s.excu();
}
