#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;
}
