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;
int Read() {
  int val = 0, opt = 1;
  char ch;
  while (!isdigit(ch = getchar()))
    if (ch == '-') opt = -1;
  while (isdigit(ch)) (val *= 10) += ch - '0', ch = getchar();
  return val * opt;
}
int n, m, beg[100100], gt[2 * 100100], nxt[2 * 100100], cnt, tot;
int dfn[100100], low[100100], Num[100100], bNum, Now[2 * 100100], Vis[100100];
stack<int> st;
vector<int> Ans, No[100100];
void add(int u, int v) {
  nxt[++tot] = beg[u], beg[u] = tot, gt[tot] = v, Now[tot] = u;
}
void tarjin(int t, int fa) {
  low[t] = dfn[t] = ++cnt;
  for (int e = beg[t]; e; e = nxt[e])
    if (gt[e] != fa) {
      st.push(e);
      if (!dfn[gt[e]]) {
        tarjin(gt[e], t);
        low[t] = min(low[t], low[gt[e]]);
        if (dfn[t] <= low[gt[e]]) {
          bNum++;
          int stop;
          while (1) {
            stop = st.top();
            st.pop();
            if (!Vis[gt[stop]]) {
              Vis[gt[stop]] = bNum;
              Num[bNum]++;
            }
            if (!Vis[Now[stop]]) {
              Vis[Now[stop]] = bNum;
              Num[bNum]++;
            }
            No[bNum].push_back((stop + 1) / 2);
            if (stop == e) break;
          }
        }
      } else
        low[t] = min(dfn[gt[e]], low[t]);
    }
}
void work() {
  n = Read(), m = Read();
  int u, v;
  for (int i = 1; i <= m; i++) {
    u = Read(), v = Read();
    add(u, v), add(v, u);
  }
  for (int i = 1; i <= n; i++)
    if (!dfn[i]) tarjin(i, 0);
  for (int i = 1; i <= bNum; i++)
    if (Num[i] == No[i].size())
      for (auto j : No[i]) Ans.push_back(j);
  sort(Ans.begin(), Ans.end());
  printf("%d\n", Ans.size());
  for (auto i : Ans) printf("%d ", i);
}
int main(void) {
  work();
  return 0;
}
