2 0
 100000 0
 8 9
1 2
2 3
3 4
4 1
5 6
6 7
7 8
8 5
6 8
 2 1
1 2
 11 9
5 9
8 5
11 3
11 1
3 4
7 11
3 1
11 2
7 2
 7 9
7 3
7 4
1 2
2 3
3 1
3 4
4 5
5 6
6 4
 7 5
5 4
7 3
7 1
6 7
3 1
 7 8
1 2
2 3
3 4
4 1
3 5
5 6
6 7
7 3
 6 9
1 2
2 3
1 4
4 2
5 2
5 3
4 5
6 4
6 5
 7 9
1 2
2 4
4 3
3 1
2 3
4 5
5 6
6 7
7 4
 1 0
 6 7
1 2
2 3
3 1
3 4
4 5
5 6
6 4
 4 5
1 2
2 3
3 4
4 1
1 3
 100000 3
99998 99999
99999 100000
100000 99998

0

 0

 4
1 2 3 4 
 0

 6
3 4 6 7 8 9 
 9
1 2 3 4 5 6 7 8 9 
 3
2 3 5 
 8
1 2 3 4 5 6 7 8 
 0

 4
6 7 8 9 
 0

 6
1 2 3 5 6 7 
 0

 3
1 2 3 

#include <bits/stdc++.h>
const double Pi = 3.14159265;
const int M = 1e5 + 10;
const int N = 2e5 + 10;
const unsigned long long base = 163;
const int INF = 0x3f3f3f3f;
const int mod = 1e8;
const double eps = 1e-9;
const double pi = acos(-1);
using namespace std;
int n, m;
int head[M], to[N], nx[N], id[N];
int sta[N], top = 0, sz = 0;
vector<int> edge_belong[N];
int mark[N];
int node_belong[N];
int dfn[M], low[M];
int subnet[M], iscut[M];
int bcc_node_size[N];
int tot, step;
void add(int u, int v, int ID) {
  to[tot] = v;
  nx[tot] = head[u];
  id[tot] = ID;
  head[u] = tot++;
}
void dfs(int u) {
  dfn[u] = low[u] = ++step;
  for (int i = head[u]; ~i; i = nx[i]) {
    if (mark[i]) continue;
    mark[i] = mark[i ^ 1] = 1;
    int v = to[i];
    sta[++top] = i;
    if (dfn[v])
      low[u] = min(low[u], dfn[v]);
    else {
      dfs(v);
      low[u] = min(low[u], low[v]);
      if (low[v] >= dfn[u]) {
        ++subnet[u];
        iscut[u] = 1;
        ++sz;
        int now;
        do {
          now = sta[top--];
          edge_belong[sz].push_back(id[now]);
          if (node_belong[to[now]] != sz) {
            node_belong[to[now]] = sz;
            bcc_node_size[sz] += 1;
          }
          if (node_belong[to[now ^ 1]] != sz) {
            node_belong[to[now ^ 1]] = sz;
            bcc_node_size[sz] += 1;
          }
        } while (now != i);
      }
    }
  }
}
void tarjan() {
  for (int i = 1; i <= n; ++i) {
    if (!dfn[i]) {
      dfs(i);
      if (subnet[i] < 2) iscut[i] = 0;
    }
  }
}
void init(int n) {
  memset(head, -1, sizeof(head));
  memset(mark, 0, sizeof(mark));
  tot = step = top = sz = 0;
}
int main() {
  scanf("%d%d", &n, &m);
  init(n);
  for (int i = 1; i <= m; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    add(u, v, i);
    add(v, u, i);
  }
  tarjan();
  vector<int> ans;
  for (int i = 1; i <= sz; ++i) {
    if (edge_belong[i].size() == bcc_node_size[i]) {
      for (auto u : edge_belong[i]) ans.push_back(u);
    }
  }
  sort(ans.begin(), ans.end());
  printf("%d\n", (int)ans.size());
  for (auto p : ans) printf("%d ", p);
  return 0;
}
