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 N = 100006;
vector<int> G[N];
int e[N];
int x[N], y[N];
bool vis[N];
int low[N];
int depth[N];
vector<int> ans;
vector<int> bcc[N];
int bcc_cnt;
stack<int> sta;
void dfs(int now, int par, int cur_depth) {
  vis[now] = true;
  depth[now] = low[now] = cur_depth;
  for (int ii : G[now]) {
    int i = (e[ii] ^ now);
    if (i == par) continue;
    if (!vis[i]) {
      sta.push(ii);
      dfs(i, now, cur_depth + 1);
      low[now] = min(low[now], low[i]);
      if (low[i] >= cur_depth) {
        ++bcc_cnt;
        while (!sta.empty()) {
          int t = sta.top();
          sta.pop();
          bcc[bcc_cnt].push_back(t);
          if (t == ii) break;
        }
      }
    } else if (vis[i] && depth[i] < low[now]) {
      sta.push(ii);
      low[now] = min(low[now], depth[i]);
    }
  }
}
void go(int root) { dfs(root, root, 1); }
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 1; m >= i; i++) {
    scanf("%d %d", &x[i], &y[i]);
    e[i] = (x[i] ^ y[i]);
    G[x[i]].push_back(i);
    G[y[i]].push_back(i);
  }
  for (int i = 1; n >= i; i++) {
    if (!vis[i]) go(i);
  }
  for (int i = 1; bcc_cnt >= i; i++) {
    set<int> st;
    for (int j : bcc[i]) {
      st.insert(x[j]);
      st.insert(y[j]);
    }
    if ((int)st.size() == (int)bcc[i].size()) {
      for (int j : bcc[i]) {
        ans.push_back(j);
      }
    }
  }
  sort(ans.begin(), ans.end());
  printf("%d\n", (int)ans.size());
  for (int i = 0; (int)ans.size() > i; i++) {
    if (i) printf(" ");
    printf("%d", ans[i]);
  }
  puts("");
}
