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 = 200005;
struct Edge {
  int u, v;
  Edge(int uu, int vv) {
    u = uu;
    v = vv;
  }
};
stack<Edge> s;
struct edge {
  int v, next;
} edges[maxn];
int n, m;
int e, head[maxn];
int pre[maxn];
int dfs_clock;
int iscut[maxn];
int bcc_cnt;
int bccno[maxn];
vector<int> bcc[maxn];
vector<int> ecnt[maxn];
map<pair<int, int>, int> f;
void addedges(int u, int v, int no) {
  if (u > v) swap(u, v);
  f[{u, v}] = no;
  edges[e].v = v;
  edges[e].next = head[u];
  head[u] = e++;
  edges[e].v = u;
  edges[e].next = head[v];
  head[v] = e++;
}
int dfs(int u, int fa) {
  int lowu = pre[u] = ++dfs_clock;
  int child = 0;
  for (int i = head[u]; i != -1; i = edges[i].next) {
    int v = edges[i].v;
    Edge e = (Edge){u, v};
    if (!pre[v]) {
      s.push(e);
      child++;
      int lowv = dfs(v, u);
      lowu = min(lowu, lowv);
      if (lowv >= pre[u]) {
        iscut[u] = 1;
        bcc_cnt++;
        bcc[bcc_cnt].clear();
        for (;;) {
          Edge x = s.top();
          s.pop();
          ecnt[bcc_cnt].push_back(f[{min(x.u, x.v), max(x.u, x.v)}]);
          if (bccno[x.u] != bcc_cnt) {
            bcc[bcc_cnt].push_back(x.u);
            bccno[x.u] = bcc_cnt;
          }
          if (bccno[x.v] != bcc_cnt) {
            bcc[bcc_cnt].push_back(x.v);
            bccno[x.v] = bcc_cnt;
          }
          if (x.u == u && x.v == v) break;
        }
      }
    } else if (pre[v] < pre[u] && v != fa) {
      s.push(e);
      lowu = min(lowu, pre[v]);
    }
  }
  if (fa < 0 && child == 1) iscut[u] = 0;
  return lowu;
}
void init() {
  memset(pre, 0, sizeof(pre));
  memset(iscut, 0, sizeof(iscut));
  memset(head, -1, sizeof(head));
  memset(bccno, 0, sizeof(bccno));
  e = 0;
  dfs_clock = 0;
  bcc_cnt = 0;
}
pair<int, int> E[maxn];
int num[300005];
vector<int> cnt[maxn];
int main() {
  int u, v;
  scanf("%d%d", &n, &m);
  init();
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &u, &v);
    addedges(u, v, i + 1);
  }
  for (int i = 1; i <= n; i++)
    if (!pre[i]) dfs(1, -1);
  vector<int> ans;
  for (int i = 1; i <= bcc_cnt; i++) {
    if (bcc[i].size() == ecnt[i].size()) {
      for (int j = 0; j < ecnt[i].size(); j++) ans.push_back(ecnt[i][j]);
    }
  }
  sort(ans.begin(), ans.end());
  printf("%d\n", ans.size());
  for (int i = 0; i < ans.size(); i++) printf("%d ", ans[i]);
  return 0;
}
