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 = 1e5 + 5;
const int mod = 1e9 + 7;
vector<int> g_bcc[maxn], f, ans;
vector<pair<int, int> > g[maxn];
pair<int, int> edge[maxn];
int pre[maxn], low[maxn], bcc[maxn];
int dfs_t, bcc_cnt;
stack<int> ST;
void dfs(int u, int fa) {
  pre[u] = low[u] = ++dfs_t;
  for (auto vx : g[u]) {
    int v = vx.first;
    if (!pre[v]) {
      ST.push(vx.second);
      dfs(v, u);
      low[u] = min(low[u], low[v]);
      if (low[v] >= pre[u]) {
        g_bcc[++bcc_cnt].clear();
        f.clear();
        while (!ST.empty()) {
          int e = ST.top();
          f.push_back(e);
          ST.pop();
          if (bcc[edge[e].first] != bcc_cnt) {
            g_bcc[bcc_cnt].push_back(edge[e].first);
            bcc[edge[e].first] = bcc_cnt;
          }
          if (bcc[edge[e].second] != bcc_cnt) {
            g_bcc[bcc_cnt].push_back(edge[e].second);
            bcc[edge[e].second] = bcc_cnt;
          }
          if (e == vx.second) break;
        }
        if (f.size() == g_bcc[bcc_cnt].size()) {
          for (auto x : f) ans.push_back(x);
        }
      }
    } else if (pre[v] < pre[u] && v != fa) {
      ST.push(vx.second);
      low[u] = min(low[u], pre[v]);
    }
  }
}
int main() {
  int n, m, i, u, v;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= m; i++) {
    scanf("%d%d", &u, &v);
    g[u].push_back(pair<int, int>(v, i));
    g[v].push_back(pair<int, int>(u, i));
    edge[i] = pair<int, int>(u, v);
  }
  for (i = 1; i <= n; i++) {
    if (!pre[i]) dfs(i, 0);
  }
  sort(ans.begin(), ans.end());
  printf("%d\n", (int)ans.size());
  for (auto x : ans) printf("%d ", x);
  puts("");
  return 0;
}
