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 = 1.1e5;
const int MAXM = 1.1e5;
int N, M;
struct edge_t {
  int c[2];
  int other(int a) {
    assert(a == c[0] || a == c[1]);
    return a ^ c[0] ^ c[1];
  }
} E[MAXM];
int last[MAXN];
int pred[MAXM * 2];
int ind[MAXM * 2];
int tot = 0;
void addEdge(int a, int e) {
  pred[tot] = last[a];
  ind[tot] = e;
  last[a] = tot;
  tot++;
}
int disc[MAXN];
int lowVal[MAXN];
int curInd = 0;
vector<int> st;
bool vis[MAXN];
vector<int> ans;
void process(vector<int> bcc) {
  int cnt = 0;
  for (int e : bcc) {
    for (int i = 0; i < 2; i++) {
      if (!vis[E[e].c[i]]) {
        vis[E[e].c[i]] = true;
        cnt++;
      }
    }
  }
  if (cnt == int(bcc.size())) {
    for (int e : bcc) {
      ans.push_back(e + 1);
    }
  }
  for (int e : bcc) {
    for (int i = 0; i < 2; i++) {
      vis[E[e].c[i]] = false;
      cnt++;
    }
  }
}
void dfs(int cur, int prvE) {
  assert(!disc[cur]);
  curInd++;
  disc[cur] = curInd;
  lowVal[cur] = disc[cur];
  int children = 0;
  for (int z = last[cur]; z != -1; z = pred[z]) {
    int e = ind[z];
    if (e == prvE) continue;
    int nxt = E[e].other(cur);
    if (!disc[nxt]) {
      st.push_back(e);
      children++;
      dfs(nxt, e);
      lowVal[cur] = min(lowVal[cur], lowVal[nxt]);
      if ((disc[cur] == 1 && children > 1) ||
          (disc[cur] != 1 && disc[cur] <= lowVal[nxt])) {
        vector<int> bcc;
        int lastE;
        do {
          lastE = st.back();
          st.pop_back();
          bcc.push_back(lastE);
        } while (lastE != e);
        process(bcc);
      }
    } else if (disc[nxt] < disc[cur]) {
      st.push_back(e);
      lowVal[cur] = min(lowVal[cur], disc[nxt]);
    }
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  cin >> N >> M;
  for (int i = 1; i <= N; i++) {
    last[i] = -1;
  }
  for (int e = 0; e < M; e++) {
    cin >> E[e].c[0] >> E[e].c[1];
    addEdge(E[e].c[0], e);
    addEdge(E[e].c[1], e);
  }
  for (int i = 1; i <= N; i++) {
    if (!disc[i]) {
      dfs(i, -1);
    }
  }
  if (!st.empty()) {
    process(st);
  }
  cout << ans.size() << '\n';
  sort(ans.begin(), ans.end());
  for (int e : ans) {
    cout << e << ' ';
  }
  cout << '\n';
  return 0;
}
