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>
template <class T>
inline T read(const T sample) {
  T x = 0;
  int f = 1;
  char s;
  while ((s = getchar()) > '9' || s < '0')
    if (s == '-') f = -1;
  while (s >= '0' && s <= '9')
    x = (x << 1) + (x << 3) + (s ^ 48), s = getchar();
  return x * f;
}
template <class T>
inline void write(const T x) {
  if (x < 0) return (void)(putchar('-'), write(-x));
  if (x > 9) write(x / 10);
  putchar(x % 10 ^ 48);
}
template <class T>
inline T Max(const T x, const T y) {
  if (x > y) return x;
  return y;
}
template <class T>
inline T Min(const T x, const T y) {
  if (x < y) return x;
  return y;
}
template <class T>
inline T fab(const T x) {
  return x > 0 ? x : -x;
}
template <class T>
inline T Gcd(const T x, const T y) {
  return y ? Gcd(y, x % y) : x;
}
template <class T>
inline T Swap(T &x, T &y) {
  x ^= y ^= x ^= y;
}
using namespace std;
const int N = 1e5 + 5;
int n, m, head[N], nxt[N << 1], to[N << 1], cnt, dfn[N], low[N], be[N], tot,
    sta[N], tp, bl, siz[N];
set<int> ans, dot[N], edge[N];
void addEdge(int u, int v) {
  nxt[++cnt] = head[u], to[cnt] = v, head[u] = cnt;
  nxt[++cnt] = head[v], to[cnt] = u, head[v] = cnt;
}
void tarjan(int u, int fa) {
  dfn[u] = low[u] = ++tot;
  for (signed i = head[u], v = to[i]; i; i = nxt[i], v = to[i]) {
    if (!dfn[v]) {
      sta[++tp] = (i + 1 >> 1), sta[++tp] = u, sta[++tp] = v;
      tarjan(v, u), low[u] = Min(low[u], low[v]);
      if (dfn[u] <= low[v]) {
        ++bl;
        int x, y;
        while (233) {
          dot[bl].insert(x = sta[tp--]);
          dot[bl].insert(y = sta[tp--]);
          edge[bl].insert(sta[tp--]);
          if (x == v && y == u) break;
        }
      }
    } else if (dfn[v] < dfn[u] && (v ^ fa)) {
      low[u] = Min(low[u], dfn[v]);
      sta[++tp] = (i + 1 >> 1), sta[++tp] = u, sta[++tp] = v;
    }
  }
}
int main() {
  n = read(9), m = read(9);
  for (register signed i = (1), _end = (m); i <= _end; ++i)
    addEdge(read(9), read(9));
  for (register signed i = (1), _end = (n); i <= _end; ++i)
    if (!dfn[i]) tarjan(i, 0);
  for (register signed i = (1), _end = (bl); i <= _end; ++i)
    if (edge[i].size() == dot[i].size())
      ans.insert(edge[i].begin(), edge[i].end());
  write(ans.size()), putchar('\n');
  set<int>::iterator it;
  for (it = ans.begin(); it != ans.end(); ++it) write(*it), putchar(' ');
  puts("");
  return 0;
}
