#include <bits/stdc++.h>
int elist[200000];
bool vis[100000];
bool evis[100000];
int pre[100000];
int pre_max = 0;
int low[100000];
std::vector<int> adj[100000];
std::vector<int> treee[100000];
std::vector<int> backe[100000];
int bcc[100000];
int nbccs = 0;
int extra[100000];
void dfs0(int node) {
  if (vis[node]) return;
  vis[node] = true;
  low[node] = pre[node] = pre_max++;
  for (int e : adj[node]) {
    if (evis[e >> 1]) continue;
    evis[e >> 1] = true;
    if (vis[elist[e ^ 1]]) {
      backe[node].push_back(e);
    } else {
      treee[node].push_back(e);
      dfs0(elist[e ^ 1]);
    }
  }
  for (int e : treee[node]) {
    low[node] = std::min(low[node], low[elist[e ^ 1]]);
  }
  for (int e : backe[node]) {
    low[node] = std::min(low[node], pre[elist[e ^ 1]]);
  }
}
std::vector<int> stk;
void dfs1(int node) {
  for (int e : treee[node]) {
    if (low[elist[e ^ 1]] >= pre[node]) {
      stk.push_back(nbccs++);
    }
    bcc[e >> 1] = stk.back();
    dfs1(elist[e ^ 1]);
    if (low[elist[e ^ 1]] >= pre[node]) {
      stk.pop_back();
    }
  }
  for (int e : backe[node]) {
    bcc[e >> 1] = stk.back();
    extra[stk.back()]++;
  }
}
int main() {
  int N, M;
  scanf("%d %d", &N, &M);
  for (int i = 0; i < M; i++) {
    int U, V;
    scanf("%d %d", &U, &V);
    U--, V--;
    elist[i * 2] = U;
    elist[i * 2 + 1] = V;
    adj[U].push_back(i * 2);
    adj[V].push_back(i * 2 + 1);
  }
  for (int i = 0; i < N; i++) {
    if (!vis[i]) {
      dfs0(i);
      dfs1(i);
    }
  }
  std::vector<int> vs;
  for (int i = 0; i < M; i++) {
    if (extra[bcc[i]] == 1) {
      vs.push_back(i);
    }
  }
  printf("%d\n", (int)vs.size());
  for (int i = 0; i < vs.size(); i++) {
    if (i) printf(" ");
    printf("%d", vs[i] + 1);
  }
  printf("\n");
  return 0;
}
