#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
const int M = 1e5 + 10;
int n, m;
int dfs_clock, ecnt;
int head[N];
int low[N];
int dfn[N];
int vis[N];
int ans[N];
struct Edge {
  int to, next, ind;
} e[M << 1];
inline void adde(int x, int y, int z) {
  e[++ecnt].to = y;
  e[ecnt].next = head[x];
  head[x] = ecnt;
  e[ecnt].ind = z;
}
stack<int> S, E;
void tarjan(int x) {
  dfn[x] = low[x] = ++dfs_clock;
  S.push(x);
  for (int i = head[x]; i; i = e[i].next) {
    int v = e[i].to;
    int cur = E.size();
    if (!vis[e[i].ind]) {
      vis[e[i].ind] = 1;
      E.push(e[i].ind);
    }
    if (!dfn[v]) {
      tarjan(v);
      low[x] = min(low[v], low[x]);
      if (low[v] >= dfn[x]) {
        int sum = 1;
        int z;
        do {
          z = S.top();
          S.pop();
          sum++;
        } while (z != v);
        int ok = (sum == (E.size() - cur));
        while (E.size() > cur) {
          ans[E.top()] = ok;
          E.pop();
        }
      }
    } else
      low[x] = min(low[x], dfn[v]);
  }
  return;
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; ++i) {
    int la, lb;
    scanf("%d %d", &la, &lb);
    adde(la, lb, i);
    adde(lb, la, i);
  }
  for (int i = 1; i <= n; ++i) {
    if (!dfn[i]) {
      tarjan(i);
    }
  }
  cout << accumulate(ans + 1, ans + 1 + m, 0) << endl;
  for (int i = 1; i <= m; ++i) {
    if (ans[i]) cout << i << " ";
  }
  return 0;
}
