#include <bits/stdc++.h>
const int MAXN = 3e5 + 10;
const double eps = 1e-8;
const int mod = 1e9 + 9;
using namespace std;
struct edge {
  int t, v;
  edge *next;
} e[MAXN << 1], *h[MAXN], *o = e;
void add(int x, int y, int vul) {
  o->t = y;
  o->v = vul;
  o->next = h[x];
  h[x] = o++;
}
long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return x * f;
}
bool vis[MAXN], Cnode[MAXN];
int dfn[MAXN], low[MAXN], cnt;
void tarjan_node(int x, int pre) {
  vis[x] = 1;
  dfn[x] = low[x] = ++cnt;
  for (edge *j = h[x]; j; j = j->next) {
    if (vis[j->t] && dfn[j->t] < dfn[x] && j->t != pre) {
      low[x] = min(low[x], dfn[j->t]);
    } else if (!vis[j->t]) {
      tarjan_node(j->t, x);
      if (low[j->t] >= dfn[x]) Cnode[x] = 1;
      low[x] = min(low[x], low[j->t]);
    }
  }
}
int num;
typedef struct node {
  int x, y;
} node;
node d[MAXN];
vector<int> p[MAXN];
int st[MAXN], tot, bcc_pos[MAXN];
int ans[MAXN];
bool pis[MAXN];
void tarjan_Bcc(int x, int pre) {
  vis[x] = 1;
  dfn[x] = low[x] = ++cnt;
  int ch = 0;
  for (edge *j = h[x]; j; j = j->next) {
    if (vis[j->t] && dfn[j->t] < dfn[x] && j->t != pre) {
      st[++tot] = j->v;
      pis[j->v] = 1;
      low[x] = min(low[x], dfn[j->t]);
    } else if (!vis[j->t]) {
      ch++;
      st[++tot] = j->v;
      tarjan_Bcc(j->t, x);
      low[x] = min(low[x], low[j->t]);
      if (low[j->t] >= dfn[x]) {
        Cnode[x] = 1;
        num++;
        p[num].clear();
        while (1) {
          int y = st[tot--];
          if (pis[y]) ans[num]++;
          p[num].push_back(y);
          if (bcc_pos[d[y].x] != num) {
            bcc_pos[d[y].x] = num;
          }
          if (bcc_pos[d[y].y] != num) {
            bcc_pos[d[y].y] = num;
          }
          if (y == j->v) break;
        }
      }
    }
  }
  if (!pre && ch <= 1) Cnode[x] = 0;
}
vector<int> vec;
int n, m;
int main() {
  n = read();
  m = read();
  int x, y;
  for (int i = 1; i <= m; i++)
    d[i].x = read(), d[i].y = read(), add(d[i].x, d[i].y, i),
    add(d[i].y, d[i].x, i);
  for (int i = 1; i <= n; i++)
    if (!vis[i]) tarjan_Bcc(i, 0);
  for (int i = 1; i <= num; i++) {
    if (ans[i] != 1) continue;
    for (int j = 0; j < p[i].size(); j++) vec.push_back(p[i][j]);
  }
  sort(vec.begin(), vec.end());
  int sz = unique(vec.begin(), vec.end()) - vec.begin();
  printf("%d\n", sz);
  for (int i = 0; i < sz; i++) printf("%d ", vec[i]);
  printf("\n");
}
