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 n, m;
int tin[100001], low[100001], he[100001], v[200002], ne[200002];
int st[300003], blo[200002], tot, num, top, tt;
vector<int> ans, edge[100001], node[100001];
void add(int x, int y) { v[++tot] = y, ne[tot] = he[x], he[x] = tot; }
void tarjan(int x, int f) {
  tin[x] = low[x] = ++num;
  for (int i = he[x]; i; i = ne[i]) {
    int y = v[i];
    if (!tin[y]) {
      st[++top] = i >> 1, st[++top] = x, st[++top] = y;
      tarjan(y, x);
      low[x] = min(low[x], low[y]);
      if (low[y] >= tin[x]) {
        tt++;
        while (1) {
          int t1 = st[top--], t2 = st[top--];
          if (blo[t1] != tt) {
            node[tt].push_back(t1);
            blo[t1] = tt;
          }
          if (blo[t2] != tt) {
            node[tt].push_back(t2);
            blo[t2] = tt;
          }
          edge[tt].push_back(st[top--]);
          if (t1 == y && t2 == x) break;
        }
      }
    } else if (tin[y] < tin[x] && y != f) {
      st[++top] = i >> 1, st[++top] = x, st[++top] = y;
      low[x] = min(low[x], tin[y]);
    }
  }
}
int main() {
  memset(tin, 0, sizeof(tin)), memset(low, 0, sizeof(low)),
      memset(he, 0, sizeof(he)), memset(ne, 0, sizeof(ne)),
      memset(v, 0, sizeof(v)), memset(st, 0, sizeof(st)),
      memset(blo, 0, sizeof(blo));
  scanf("%d%d", &n, &m);
  tot = 1;
  num = top = tt = 0;
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (x == y) continue;
    add(x, y), add(y, x);
  }
  for (int i = 1; i <= n; i++)
    if (!tin[i]) tarjan(i, 0);
  for (int i = 1; i <= tt; i++) {
    if (edge[i].size() == node[i].size()) {
      for (int j = 0; j < edge[i].size(); j++) ans.push_back(edge[i][j]);
    }
  }
  sort(ans.begin(), ans.end());
  printf("%d\n", ans.size());
  for (int i = 0; i < ans.size(); i++) {
    if (i == 0)
      printf("%d", ans[i]);
    else
      printf(" %d", ans[i]);
  }
  return 0;
}
