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 nmax = 1e5;
const int inf = 1 << 30;
bool viz[nmax + 1], f[nmax + 1];
int h[nmax + 1];
int d[nmax + 1];
int nrc;
int noduri[nmax + 1][2];
vector<int> c[nmax + 1];
vector<pair<int, int> > g[nmax + 1];
void dfs(int nod, int mtata) {
  viz[nod] = 1;
  d[nod] = inf;
  for (auto i : g[nod]) {
    if (i.second != mtata) {
      if (viz[i.first] == 0) {
        h[i.first] = h[nod] + 1;
        dfs(i.first, i.second);
        d[nod] = min(d[nod], d[i.first]);
      } else {
        d[nod] = min(d[nod], h[i.first]);
      }
    }
  }
}
void comp(int nod, int ind, int mtata) {
  viz[nod] = 1;
  for (auto i : g[nod]) {
    if (viz[i.first] == 0) {
      if (d[i.first] >= h[nod]) {
        ++nrc;
        c[nrc].push_back(i.second);
        comp(i.first, nrc, i.second);
      } else {
        c[ind].push_back(i.second);
        comp(i.first, ind, i.second);
      }
    } else if (i.second != mtata && h[i.first] < h[nod]) {
      c[ind].push_back(i.second);
    }
  }
}
int main() {
  int n, m;
  fscanf(stdin, "%d%d", &n, &m);
  for (int i = 1; i <= m; ++i) {
    int x, y;
    fscanf(stdin, "%d%d", &x, &y);
    g[x].push_back({y, i});
    g[y].push_back({x, i});
    noduri[i][0] = x;
    noduri[i][1] = y;
  }
  for (int i = 1; i <= n; ++i) {
    if (viz[i] == 0) {
      dfs(i, 0);
    }
  }
  memset(viz, 0, sizeof(viz));
  nrc = 0;
  for (int i = 1; i <= n; ++i) {
    if (viz[i] == 0) {
      comp(i, 0, 0);
    }
  }
  vector<int> ans;
  for (int i = 1; i <= nrc; ++i) {
    int cnt = 0;
    sort(c[i].begin(), c[i].end());
    c[i].erase(unique(c[i].begin(), c[i].end()), c[i].end());
    m -= (int)c[i].size();
    for (auto j : c[i]) {
      for (int k = 0; k < 2; ++k) {
        int x = noduri[j][k];
        if (f[x] == 0) ++cnt;
        f[x] = 1;
      }
    }
    if (cnt == (int)c[i].size()) {
      for (auto j : c[i]) ans.push_back(j);
    }
    for (auto j : c[i]) {
      for (int k = 0; k < 2; ++k) {
        int x = noduri[j][k];
        f[x] = 0;
      }
    }
  }
  assert(m == 0);
  sort(ans.begin(), ans.end());
  fprintf(stdout, "%d\n", (int)ans.size());
  for (auto i : ans) fprintf(stdout, "%d ", i);
  return 0;
}
