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;
inline int read() {
  int x = 0, f = 0;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = 1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  if (f) x = -x;
  return x;
}
int a[100005], fa[100005], fd[100005], dep[100005], n, m;
int ans[200005], sta[100005], top[100005], cnt = 0;
int head[100005], nxt[200005], v[200005], id[200005], tot = 0;
bool vis[100005], ins[100005];
vector<int> vec[100005];
inline int getf(int a) {
  while (top[a] ^ a) a = top[a] = top[top[a]];
  return a;
}
inline void add(int a, int b, int qwq) {
  tot++;
  nxt[tot] = head[a];
  head[a] = tot;
  v[tot] = b;
  id[tot] = qwq;
}
inline void cover(int id, int a, int b) {
  int tag = 1;
  for (int i = a; i != b; i = fa[i]) {
    if (sta[i] > 0 || sta[i] == -1) {
      tag = 0;
      break;
    }
  }
  if (tag == 1) {
    for (int i = a; i != b; i = fa[i]) {
      sta[i] = id;
      vec[id].push_back(i);
    }
    return;
  }
  int i = a;
  while (dep[i] > dep[b]) {
    if (sta[i] == 0) {
      sta[i] = -1;
      top[i] = fa[i];
      i = fa[i];
      continue;
    }
    if (sta[i] == -1) {
      i = getf(i);
      continue;
    }
    if (sta[i] > 0) {
      int p = sta[i], j;
      for (j = 0; j < vec[p].size(); j++) {
        sta[vec[p][j]] = -1;
        top[vec[p][j]] = fa[vec[p][j]];
      }
      vec[p].clear();
      i = fa[i];
    }
  }
}
void dfs(int pos, int f) {
  vis[pos] = ins[pos] = 1;
  for (int i = head[pos]; i; i = nxt[i]) {
    if (v[i] == f) continue;
    if (vis[v[i]] && ins[v[i]]) {
      cover(id[i], pos, v[i]);
      continue;
    }
    if (vis[v[i]]) continue;
    dep[v[i]] = dep[pos] + 1;
    fa[v[i]] = pos;
    fd[v[i]] = id[i];
    dfs(v[i], pos);
  }
  ins[pos] = 0;
}
int main() {
  int i, j, a, b;
  n = read();
  m = read();
  for (i = 1; i <= m; i++) {
    a = read();
    b = read();
    add(a, b, i);
    add(b, a, i);
  }
  for (i = 1; i <= n; i++) top[i] = i;
  for (i = 1; i <= n; i++) {
    if (!vis[i]) dfs(i, 0);
  }
  for (i = 1; i <= n; i++) {
    if (sta[i] > 0) {
      ans[++cnt] = sta[i];
      ans[++cnt] = fd[i];
    }
  }
  sort(ans + 1, ans + cnt + 1);
  cnt = unique(ans + 1, ans + cnt + 1) - ans - 1;
  printf("%d\n", cnt);
  for (i = 1; i <= cnt; i++) {
    printf("%d ", ans[i]);
  }
  return 0;
}
