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 = 100005;
const int MAXM = 500005;
inline int read() {
  int weight = 0, symbol = 1;
  char in = getchar();
  while (!isdigit(in)) {
    if (in == '-') symbol = -1;
    in = getchar();
  }
  while (isdigit(in)) {
    weight = weight * 10 + in - '0';
    in = getchar();
  }
  return symbol * weight;
}
int n, m;
int head[MAXN];
struct EDGE {
  int from, to;
  int next;
  bool ch;
} edge[MAXM];
int edge_cnt = 1;
void add_edge(int fr, int to) {
  edge[++edge_cnt].from = fr;
  edge[edge_cnt].to = to;
  edge[edge_cnt].next = head[fr];
  head[fr] = edge_cnt;
}
int depth[MAXN], fa[MAXN];
int etofa[MAXN];
bool vis[MAXN];
void dfs_build(int x, int fath) {
  depth[x] = depth[fath] + 1, vis[x] = 1;
  fa[x] = fath;
  for (int i = head[x]; i; i = edge[i].next) {
    int y = edge[i].to;
    if (vis[y]) continue;
    etofa[y] = i;
    edge[i].ch = 1;
    dfs_build(y, x);
  }
}
int sum[MAXM];
void dfs_sum(int x, int fath) {
  vis[x] = 1;
  for (int i = head[x]; i; i = edge[i].next) {
    int y = edge[i].to;
    if (!edge[i].ch) continue;
    dfs_sum(y, x);
    sum[x] += sum[y];
  }
}
vector<int> ans;
int main() {
  n = read(), m = read();
  for (int i = 1; i <= m; i++) {
    int u = read(), v = read();
    add_edge(u, v), add_edge(v, u);
  }
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) dfs_build(i, 0);
  }
  for (int i = 2; i <= edge_cnt; i += 2) {
    if (edge[i].ch || edge[i ^ 1].ch) continue;
    int fr = edge[i].from, to = edge[i].to;
    if (depth[fr] < depth[to]) swap(fr, to);
    sum[fr]++, sum[to]--;
  }
  memset(vis, 0, sizeof(vis));
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) dfs_sum(1, 0);
  }
  for (int i = 2; i <= edge_cnt; i += 2) {
    if (edge[i].ch || edge[i ^ 1].ch) continue;
    int fr = edge[i].from, to = edge[i].to;
    if (depth[fr] < depth[to]) swap(fr, to);
    bool ch = 0;
    int pos = fr;
    for (; fa[pos] != to; pos = fa[pos]) {
      if (sum[pos] != 1) {
        ch = 1;
        break;
      }
    }
    if (ch || sum[pos] != 1) continue;
    ans.push_back(i >> 1);
    while (fr != to) {
      ans.push_back(etofa[fr] >> 1);
      fr = fa[fr];
    }
  }
  sort(ans.begin(), ans.end());
  printf("%d\n", ans.size());
  for (int i = 0; i < ans.size(); i++) printf("%d ", ans[i]);
  return 0;
}
