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 MX = 1e5 + 1;
int up[MX], col[MX], nxt[MX], par[MX], cnt[MX], edge[MX];
vector<pair<int, int>> adj[MX];
int find(int a) {
  if (par[a] != a) {
    par[a] = find(par[a]);
  }
  return par[a];
}
void unite(int a, int b) {
  a = find(a);
  b = find(b);
  if (a != b) {
    par[a] = b;
    cnt[b] += cnt[a];
  }
}
int dfs(int u, int p) {
  col[u] = 1;
  int res = 0;
  for (auto e : adj[u]) {
    int c, i;
    tie(c, i) = e;
    if (c == p) continue;
    if (col[c] == 1) {
      ++cnt[find(edge[u])];
      unite(i, edge[u]);
      ++up[nxt[c]];
      ++res;
    } else if (!col[c]) {
      nxt[u] = c;
      edge[c] = i;
      int chd = dfs(c, u);
      res += chd;
      if (chd) {
        unite(edge[u], edge[c]);
      }
    }
  }
  col[u] = 2;
  return res - up[u];
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    int u, v;
    cin >> u >> v;
    adj[u].emplace_back(v, i);
    adj[v].emplace_back(u, i);
  }
  iota(par, par + 1 + n, 0);
  dfs(1, 0);
  vector<int> ans;
  for (int i = 1; i <= m; ++i) {
    if (cnt[find(i)] == 1) {
      ans.push_back(i);
    }
  }
  cout << ans.size() << '\n';
  for (auto i : ans) {
    cout << i << ' ';
  }
  cout << '\n';
}
