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 long long QuickPow(long long x, long long y) {
  long long Res = 1, Temp = x;
  while (y) {
    if (y & 1) Res = Res * Temp % 1000000007;
    Temp = Temp * Temp % 1000000007;
    y /= 2;
  }
  return Res;
}
inline void Swap(long long &x, long long &y) {
  long long Temp = x;
  x = y;
  y = Temp;
}
inline long long Max(long long x, long long y) { return x > y ? x : y; }
inline long long Min(long long x, long long y) { return x < y ? x : y; }
inline void read(long long &x) {
  x = 0;
  long long f = 1;
  char s = getchar();
  while (s < '0' || s > '9') {
    if (s == '-') f = -1;
    s = getchar();
  }
  while (s >= '0' && s <= '9') {
    x = (x << 3) + (x << 1) + (s ^ 48);
    s = getchar();
  }
  x *= f;
}
struct node {
  long long v, Index;
  node() {}
  node(long long V, long long INDEX) {
    v = V;
    Index = INDEX;
  }
};
set<long long> Ans, Bian[100005], Dian[100005];
set<long long>::iterator item;
stack<long long> S;
vector<node> G[100005];
bool InStack[100005];
long long Dfn[100005], Low[100005], Cnt, Col;
void Tarjan(long long x, long long Pre) {
  Dfn[x] = Low[x] = ++Cnt;
  int l = G[x].size();
  for (register long long i = 0; i < l; ++i) {
    long long to = G[x][i].v;
    if (to == Pre) continue;
    if (!Dfn[to]) {
      S.push(to);
      S.push(x);
      S.push(G[x][i].Index);
      Tarjan(to, x);
      Low[x] = Min(Low[x], Low[to]);
      if (Low[to] >= Dfn[x]) {
        Col++;
        long long u, v;
        do {
          Bian[Col].insert(S.top());
          S.pop();
          u = S.top();
          S.pop();
          v = S.top();
          S.pop();
          Dian[Col].insert(u);
          Dian[Col].insert(v);
        } while (u != x || v != to);
      }
    } else if (Dfn[to] < Dfn[x]) {
      S.push(to);
      S.push(x);
      S.push(G[x][i].Index);
      Low[x] = Min(Low[x], Dfn[to]);
    }
  }
}
int main() {
  long long n, m;
  read(n);
  read(m);
  for (register long long i = 1; i <= m; ++i) {
    long long u, v;
    read(u);
    read(v);
    G[u].push_back(node(v, i));
    G[v].push_back(node(u, i));
  }
  for (register long long i = 1; i <= n; ++i)
    if (!Dfn[i]) Tarjan(i, i);
  for (register long long i = 1; i <= Col; ++i)
    if (Bian[i].size() == Dian[i].size())
      Ans.insert(Bian[i].begin(), Bian[i].end());
  int l = Ans.size();
  printf("%d\n", l);
  for (item = Ans.begin(); item != Ans.end(); item++) printf("%lld ", *item);
  return 0;
}
