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>
using namespace std;
const int maxn = 300005;
struct Edge {
  int no, v, next;
} edges[maxn];
int n, m, ebcnum;
int e, head[maxn];
int pre[maxn];
int dfs_clock;
int isbridge[maxn];
pair<int, int> E[maxn];
vector<int> ebc[maxn];
int num[300005];
vector<int> cnt[maxn];
void addedges(int num, int u, int v) {
  edges[e].no = num;
  edges[e].v = v;
  edges[e].next = head[u];
  head[u] = e++;
  edges[e].no = num++;
  edges[e].v = u;
  edges[e].next = head[v];
  head[v] = e++;
}
int dfs_findbridge(int u, int fa) {
  int lowu = pre[u] = ++dfs_clock;
  for (int i = head[u]; i != -1; i = edges[i].next) {
    int v = edges[i].v;
    if (!pre[v]) {
      int lowv = dfs_findbridge(v, u);
      lowu = min(lowu, lowv);
      if (lowv > pre[u]) {
        isbridge[edges[i].no] = 1;
      }
    } else if (pre[v] < pre[u] && v != fa) {
      lowu = min(lowu, pre[v]);
    }
  }
  return lowu;
}
void dfs_coutbridge(int u, int fa) {
  ebc[ebcnum].push_back(u);
  pre[u] = ++dfs_clock;
  for (int i = head[u]; i != -1; i = edges[i].next) {
    int v = edges[i].v;
    if (!isbridge[edges[i].no] && !pre[v]) dfs_coutbridge(v, u);
  }
}
void init() {
  memset(pre, 0, sizeof(pre));
  memset(isbridge, 0, sizeof(isbridge));
  memset(head, -1, sizeof(head));
  e = 0;
  ebcnum = 0;
}
int main() {
  int u, v;
  scanf("%d%d", &n, &m);
  init();
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &u, &v);
    E[i] = pair<int, int>(u, v);
    addedges(i, u, v);
  }
  dfs_findbridge(1, -1);
  memset(pre, 0, sizeof(pre));
  for (int i = 1; i <= n; i++) {
    if (!pre[i]) {
      ebc[ebcnum].clear();
      dfs_coutbridge(i, -1);
      ebcnum++;
    }
  }
  for (int i = 0; i < ebcnum; i++) {
    for (int j = 0; j < ebc[i].size(); j++) num[ebc[i][j]] = i;
  }
  for (int i = 0; i < m; i++)
    if (num[E[i].first] == num[E[i].second]) cnt[num[E[i].first]].push_back(i);
  vector<int> ans;
  for (int i = 0; i < ebcnum; i++)
    if (cnt[i].size() == ebc[i].size()) {
      for (int j = 0; j < cnt[i].size(); j++) ans.push_back(cnt[i][j]);
    }
  sort(ans.begin(), ans.end());
  printf("%d\n", ans.size());
  for (int i = 0; i < ans.size(); i++) printf("%d ", ans[i] + 1);
  return 0;
}
