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 N = 100005;
struct qq {
  int x, y, last;
} e[N * 2];
int num, last[N];
int n, m;
void init(int x, int y) {
  num++;
  e[num].x = x;
  e[num].y = y;
  e[num].last = last[x];
  last[x] = num;
}
int dfn[N], low[N], id;
int sta[N], top;
int h[N], cnt;
int belong[N];
void dfs(int x) {
  low[x] = dfn[x] = ++id;
  sta[++top] = x;
  for (int u = last[x]; u != -1; u = e[u].last) {
    int y = e[u].y;
    if (dfn[y] == -1) {
      dfs(y);
      low[x] = min(low[x], low[y]);
      if (low[y] >= dfn[x]) {
        cnt++;
        int i;
        do {
          i = sta[top--];
          h[cnt]++;
          belong[i] = cnt;
        } while (i != y);
        h[cnt]++;
      }
    } else
      low[x] = min(low[x], dfn[y]);
  }
}
vector<int> s[N];
int ans[N];
int main() {
  num = 0;
  memset(last, -1, sizeof(last));
  scanf("%d%d", &n, &m);
  for (int u = 1; u <= m; u++) {
    int x, y;
    scanf("%d%d", &x, &y);
    init(x, y);
    init(y, x);
  }
  memset(dfn, -1, sizeof(dfn));
  id = 0;
  top = 0;
  cnt = 0;
  for (int u = 1; u <= n; u++)
    if (dfn[u] == -1) {
      dfs(u);
      cnt++;
      while (top > 0) {
        h[cnt]++;
        top--;
      }
    }
  for (int u = 1; u <= m; u++) {
    int xx = u * 2 - 1;
    int x = dfn[e[xx].x] > dfn[e[xx].y] ? e[xx].x : e[xx].y;
    s[belong[x]].push_back(u);
  }
  for (int u = 1; u <= cnt; u++)
    if (s[u].size() == h[u]) {
      for (int i = 0; i < s[u].size(); i++) ans[++ans[0]] = s[u][i];
    }
  sort(ans + 1, ans + 1 + ans[0]);
  printf("%d\n", ans[0]);
  for (int u = 1; u <= ans[0]; u++) printf("%d ", ans[u]);
  printf("\n");
  return 0;
}
