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 maxn = 1e5 + 55;
namespace Fast_IO {
const int MAXL((1 << 18) + 1);
int iof, iotp;
char ioif[MAXL], *ioiS, *ioiT, ioof[MAXL],
    *iooS = ioof, *iooT = ioof + MAXL - 1, ioc, iost[55];
char Getchar() {
  if (ioiS == ioiT) {
    ioiS = ioif;
    ioiT = ioiS + fread(ioif, 1, MAXL, stdin);
    return (ioiS == ioiT ? EOF : *ioiS++);
  } else
    return (*ioiS++);
}
void Write() {
  fwrite(ioof, 1, iooS - ioof, stdout);
  iooS = ioof;
}
void Putchar(char x) {
  *iooS++ = x;
  if (iooS == iooT) Write();
}
inline int read() {
  int x = 0;
  for (iof = 1, ioc = Getchar(); (ioc < '0' || ioc > '9') && ioc != EOF;)
    iof = ioc == '-' ? -1 : 1, ioc = Getchar();
  if (ioc == EOF) exit(0);
  for (x = 0; ioc <= '9' && ioc >= '0'; ioc = Getchar())
    x = (x << 3) + (x << 1) + (ioc ^ 48);
  return x * iof;
}
inline long long read_ll() {
  long long x = 0;
  for (iof = 1, ioc = Getchar(); (ioc < '0' || ioc > '9') && ioc != EOF;)
    iof = ioc == '-' ? -1 : 1, ioc = Getchar();
  if (ioc == EOF) exit(0);
  for (x = 0; ioc <= '9' && ioc >= '0'; ioc = Getchar())
    x = (x << 3) + (x << 1) + (ioc ^ 48);
  return x * iof;
}
template <class Int>
void Print(Int x, char ch = '\0') {
  if (!x) Putchar('0');
  if (x < 0) Putchar('-'), x = -x;
  while (x) iost[++iotp] = x % 10 + '0', x /= 10;
  while (iotp) Putchar(iost[iotp--]);
  if (ch) Putchar(ch);
}
void Getstr(char *s, int &l) {
  for (ioc = Getchar(); ioc == ' ' || ioc == '\n' || ioc == '\t';)
    ioc = Getchar();
  if (ioc == EOF) exit(0);
  for (l = 0; !(ioc == ' ' || ioc == '\n' || ioc == '\t' || ioc == EOF);
       ioc = Getchar())
    s[l++] = ioc;
  s[l] = 0;
}
void Putstr(const char *s) {
  for (int i = 0, n = strlen(s); i < n; ++i) Putchar(s[i]);
}
}  // namespace Fast_IO
using namespace Fast_IO;
int ans1, ans2, cc;
struct node {
  int to, nxt, id;
} e[maxn * 2];
int head[maxn], ct;
void add(int u, int v, int id) {
  e[++ct].to = v;
  e[ct].nxt = head[u];
  e[ct].id = id;
  head[u] = ct;
}
int dfn[maxn], low[maxn], cnt, sta[maxn], top, a[maxn], ans[maxn], ccnt, n, m,
    vis[maxn], jishu;
bool flag[maxn];
void tarjan(int u, int fa) {
  dfn[u] = low[u] = ++cnt;
  sta[++top] = u;
  for (int i = head[u]; i != 0; i = e[i].nxt) {
    int v = e[i].to;
    if (v == fa) continue;
    if (!dfn[v]) {
      tarjan(v, u);
      low[u] = min(low[u], low[v]);
      if (low[v] == dfn[u]) {
        jishu++;
        cc = 0;
        int x;
        do {
          x = sta[top--];
          vis[x] = jishu;
          a[cc++] = x;
        } while (x != v);
        a[cc++] = u;
        vis[u] = jishu;
        int sum = 0;
        for (int j = 0; j < cc; j++) {
          int uu = a[j];
          for (int k = head[uu]; k != 0; k = e[k].nxt) {
            long long tt = e[k].to;
            if (vis[tt] == jishu) sum++;
          }
        }
        sum /= 2;
        if (sum == cc) {
          ans2 += sum;
          for (int j = 0; j < cc; j++) {
            int uu = a[j];
            for (int k = head[uu]; k != 0; k = e[k].nxt) {
              int tt = e[k].to;
              if (vis[tt] == jishu && !flag[e[k].id]) {
                flag[e[k].id] = 1;
              }
            }
          }
        }
      }
    } else
      low[u] = min(low[u], dfn[v]);
  }
}
int main() {
  n = read(), m = read();
  memset(head, 0, sizeof(head));
  for (int i = 1; i <= m; ++i) {
    int u = read(), v = read();
    add(u, v, i);
    add(v, u, i);
  }
  for (int i = 1; i <= n; ++i)
    if (!dfn[i]) tarjan(i, -1);
  printf("%d\n", ans2);
  for (int i = 1; i <= m; i++)
    if (flag[i]) printf("%d ", i);
  putchar(10);
}
