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;
struct ee {
  int to, nt;
} e[404040];
int n, m, ct = 1, tt, a[202020], bl[202020], hd[202020], xu[202020], lw[202020],
          sk[202020], tp, nw, ne, nd;
bool vis[404040];
vector<int> ans;
void add(int x, int y) {
  ct++;
  e[ct].to = y;
  e[ct].nt = hd[x];
  hd[x] = ct;
}
void dfs(int x, int y) {
  tt++;
  xu[x] = tt;
  lw[x] = tt;
  for (int i = hd[x]; i; i = e[i].nt) {
    int z = e[i].to;
    if (z == y || vis[i]) {
      continue;
    }
    vis[i] = true;
    vis[i ^ 1] = true;
    tp++;
    sk[tp] = i;
    if (!xu[z]) {
      dfs(z, x);
      lw[x] = min(lw[x], lw[z]);
      if (lw[z] >= xu[x]) {
        nw++;
        int ppp;
        ne = 0;
        nd = 0;
        do {
          ppp = sk[tp];
          tp--;
          if (bl[e[ppp].to] != nw) {
            bl[e[ppp].to] = nw;
            nd++;
          }
          if (bl[e[ppp ^ 1].to] != nw) {
            bl[e[ppp ^ 1].to] = nw;
            nd++;
          }
          ne++;
          a[ne] = ppp;
        } while (ppp != i);
        if (nd == ne) {
          for (int i = 1; i <= ne; i++) {
            ans.push_back(a[i] / 2);
          }
        }
      }
    } else {
      lw[x] = min(lw[x], xu[z]);
    }
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    add(x, y);
    add(y, x);
  }
  for (int i = 1; i <= n; i++) {
    if (!xu[i]) {
      dfs(i, 0);
    }
  }
  sort(ans.begin(), ans.end());
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i] << ' ';
  }
  cout << endl;
  return 0;
}
