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>
const int MAXN = 3e5 + 10;
const double eps = 1e-8;
const int mod = 1e9 + 9;
using namespace std;
struct edge {
  int t, v;
  edge *next;
} e[MAXN << 1], *h[MAXN], *o = e;
void add(int x, int y, int vul) {
  o->t = y;
  o->v = vul;
  o->next = h[x];
  h[x] = o++;
}
long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return x * f;
}
bool vis[MAXN], Cnode[MAXN];
int dfn[MAXN], low[MAXN], cnt;
void tarjan_node(int x, int pre) {
  vis[x] = 1;
  dfn[x] = low[x] = ++cnt;
  for (edge *j = h[x]; j; j = j->next) {
    if (vis[j->t] && dfn[j->t] < dfn[x] && j->t != pre) {
      low[x] = min(low[x], dfn[j->t]);
    } else if (!vis[j->t]) {
      tarjan_node(j->t, x);
      if (low[j->t] >= dfn[x]) Cnode[x] = 1;
      low[x] = min(low[x], low[j->t]);
    }
  }
}
int num;
typedef struct node {
  int x, y;
} node;
node d[MAXN];
vector<int> p[MAXN];
int st[MAXN], tot, bcc_pos[MAXN];
int ans[MAXN];
bool pis[MAXN];
void tarjan_Bcc(int x, int pre) {
  vis[x] = 1;
  dfn[x] = low[x] = ++cnt;
  int ch = 0;
  for (edge *j = h[x]; j; j = j->next) {
    if (vis[j->t] && dfn[j->t] < dfn[x] && j->t != pre) {
      st[++tot] = j->v;
      pis[j->v] = 1;
      low[x] = min(low[x], dfn[j->t]);
    } else if (!vis[j->t]) {
      ch++;
      st[++tot] = j->v;
      tarjan_Bcc(j->t, x);
      low[x] = min(low[x], low[j->t]);
      if (low[j->t] >= dfn[x]) {
        Cnode[x] = 1;
        num++;
        p[num].clear();
        while (1) {
          int y = st[tot--];
          if (pis[y]) ans[num]++;
          p[num].push_back(y);
          if (bcc_pos[d[y].x] != num) {
            bcc_pos[d[y].x] = num;
          }
          if (bcc_pos[d[y].y] != num) {
            bcc_pos[d[y].y] = num;
          }
          if (y == j->v) break;
        }
      }
    }
  }
  if (!pre && ch <= 1) Cnode[x] = 0;
}
vector<int> vec;
int n, m;
int main() {
  n = read();
  m = read();
  int x, y;
  for (int i = 1; i <= m; i++)
    d[i].x = read(), d[i].y = read(), add(d[i].x, d[i].y, i),
    add(d[i].y, d[i].x, i);
  for (int i = 1; i <= n; i++)
    if (!vis[i]) tarjan_Bcc(i, 0);
  for (int i = 1; i <= num; i++) {
    if (ans[i] != 1) continue;
    for (int j = 0; j < p[i].size(); j++) vec.push_back(p[i][j]);
  }
  sort(vec.begin(), vec.end());
  int sz = unique(vec.begin(), vec.end()) - vec.begin();
  printf("%d\n", sz);
  for (int i = 0; i < sz; i++) printf("%d ", vec[i]);
  printf("\n");
}
