#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long maxn = 1e5 + 7;
const long long maxm = 2e5 + 7;
int low[maxn], tin[maxn], head[maxm], vis[maxn * 2];
int cnt = 0, times = 0, totn = 0;
set<int> ans;
struct EDGE {
  int to, next, id;
} p[maxm * 2];
stack<int> Skeg;
void add(int u, int v, int i) {
  p[cnt].to = v;
  p[cnt].next = head[u];
  p[cnt].id = i;
  head[u] = cnt++;
}
void tarjan(int k, int fa) {
  low[k] = tin[k] = ++times;
  int v;
  for (int i = head[k]; i != -1; i = p[i].next) {
    v = p[i].to;
    if (v == fa) continue;
    if (vis[i]) continue;
    vis[i] = vis[i ^ 1] = 1;
    Skeg.push(i);
    if (!tin[v]) {
      tarjan(v, k);
      low[k] = min(low[k], low[v]);
      if (low[v] >= tin[k]) {
        totn++;
        int t;
        set<int> ve, eg;
        ve.insert(k);
        do {
          t = Skeg.top();
          Skeg.pop();
          ve.insert(p[t].to);
          eg.insert(p[t].id);
        } while (t != i);
        if (ve.size() == eg.size()) {
          ans.insert(eg.begin(), eg.end());
        }
      }
    } else if (tin[v] < tin[k]) {
      low[k] = min(low[k], tin[v]);
    }
  }
}
int main() {
  memset(head, -1, sizeof(head));
  int n, m, u, v;
  scanf("%d", &n);
  scanf("%d", &m);
  for (register int i = 1; i <= m; i = i + 1) {
    scanf("%d", &u);
    scanf("%d", &v);
    add(u, v, i);
    add(v, u, i);
  }
  for (register int i = 1; i <= n; i = i + 1) {
    if (!tin[i]) tarjan(i, -1);
  }
  printf("%d", ans.size());
  printf("\n");
  ;
  for (auto i : ans) {
    printf("%d", i);
    printf("%s", " ");
  }
  return 0;
}
