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 maxn = 2e5 + 5;
int low[maxn], tim[maxn], now_time, iscut[maxn], belong[maxn], bcc_cnt,
    nodecnt[maxn], bccno[maxn], mark[maxn];
int n, m;
vector<int> vec[maxn], vt[maxn], ans;
struct edge {
  int u, v;
  edge() {}
  edge(int uu, int vv) : u(uu), v(vv) {}
} ed[maxn];
void init() {
  for (int i = 1; i <= n; i++) {
    vec[i].clear();
    vt[i].clear();
  }
  ans.clear();
  memset(low, 0, sizeof(low));
  memset(tim, 0, sizeof(tim));
  memset(belong, 0, sizeof(belong));
  memset(iscut, 0, sizeof(iscut));
  memset(nodecnt, 0, sizeof(nodecnt));
  memset(bccno, 0, sizeof(bccno));
  memset(mark, 0, sizeof(mark));
  now_time = bcc_cnt = 0;
}
stack<int> s;
void tarjan(int o, int fa) {
  tim[o] = low[o] = ++now_time;
  int child = 0;
  for (int i = 0; i < vec[o].size(); i++) {
    int tmp = ed[vec[o][i]].v;
    if (mark[vec[o][i]]) continue;
    mark[vec[o][i]] = mark[vec[o][i] ^ 1] = 1;
    s.push(vec[o][i]);
    if (!tim[tmp]) {
      child++;
      tarjan(tmp, o);
      low[o] = min(low[o], low[tmp]);
      if (low[tmp] >= tim[o]) {
        iscut[o] = 1;
        ++bcc_cnt;
        while (1) {
          int t = s.top();
          s.pop();
          if (bccno[ed[t].u] != bcc_cnt) {
            bccno[ed[t].u] = bcc_cnt;
            nodecnt[bcc_cnt]++;
          }
          if (bccno[ed[t].v] != bcc_cnt) {
            bccno[ed[t].v] = bcc_cnt;
            nodecnt[bcc_cnt]++;
          }
          belong[(t >> 1) + 1] = bcc_cnt;
          if (vec[o][i] == t) break;
        }
      }
    } else
      low[o] = min(tim[tmp], low[o]);
  }
  if (child == 1 && fa < 0) iscut[o] = 0;
}
int main(void) {
  while (scanf("%d%d", &n, &m) != EOF) {
    init();
    for (int i = 0; i < 2 * m; i += 2) {
      int u, v;
      scanf("%d%d", &u, &v);
      ed[i] = edge(u, v);
      ed[i + 1] = edge(v, u);
      vec[u].push_back(i);
      vec[v].push_back(i + 1);
    }
    for (int i = 1; i <= n; i++)
      if (!tim[i]) tarjan(i, -1);
    for (int i = 1; i <= m; i++) {
      vt[belong[i]].push_back(i);
    }
    for (int i = 1; i <= bcc_cnt; i++) {
      if (nodecnt[i] == vt[i].size()) {
        for (int j = 0; j < vt[i].size(); j++) ans.push_back(vt[i][j]);
      }
    }
    sort(ans.begin(), ans.end());
    printf("%d\n", ans.size());
    for (int i = 0; i < ans.size(); i++)
      printf("%d%c", ans[i], i == ans.size() - 1 ? '\n' : ' ');
  }
  return 0;
}
