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;
long long n, m, low[1200005], tnum, ans,
    tot = 1, tmp[1200005], f[1200005], vis[1200005], dfn[1200050], cnt = 0,
    nex[2200005], go[2200005], head[2200005];
stack<long long> q;
stack<long long> qq;
vector<long long> a[1200005];
void add(long long u, long long v) {
  nex[++tot] = head[u];
  head[u] = tot;
  go[tot] = v;
}
void tar(long long u) {
  dfn[u] = low[u] = ++tnum;
  qq.push(u);
  for (long long i = head[u]; i; i = nex[i]) {
    long long v = go[i];
    if (vis[i >> 1]) continue;
    vis[i >> 1] = 1;
    q.push((i >> 1));
    if (!dfn[v]) {
      tar(v);
      low[u] = min(low[u], low[v]);
      if (low[v] < dfn[u]) continue;
      cnt++;
      tmp[cnt]++;
      while (1) {
        long long tp = qq.top();
        qq.pop();
        tmp[cnt]++;
        if (tp == v) break;
      }
      while (1) {
        long long tp = q.top();
        a[cnt].push_back(tp);
        q.pop();
        if (tp == (i >> 1)) break;
      }
    }
    low[u] = min(low[u], dfn[v]);
  }
}
signed main() {
  cin >> n >> m;
  for (long long i = 1, u, v; i <= m; i++) {
    scanf("%lld%lld", &u, &v);
    add(u, v);
    add(v, u);
  }
  for (long long i = 1; i <= n; i++)
    if (!dfn[i]) tar(i);
  for (long long i = 1; i <= cnt; i++) {
    if (tmp[i] != a[i].size()) continue;
    for (long long j = 0; j < a[i].size(); j++) {
      f[a[i][j]] = 1;
    }
  }
  for (long long i = 1; i <= m; i++) {
    if (f[i]) ans++;
  }
  cout << ans << endl;
  for (long long i = 1; i <= m; i++)
    if (f[i]) cout << i << " ";
  return 0;
}
