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 = 200000 + 5, maxm = 200000 + 5;
int n, m;
struct Edge {
  int u, v, idx, nxt;
  Edge(int u = 0, int v = 0) : u(u), v(v) {}
  bool operator==(const Edge& rhs) const { return u == rhs.u && v == rhs.v; }
} edge[maxm];
int head[maxn], top;
int stamp, dfn[maxn], low[maxn], belong[maxn], bccno, bccsz[maxn];
bool iscut[maxn], vis[maxm];
stack<Edge> st;
vector<int> bcc[maxn];
void init() {
  memset(head, -1, sizeof(head));
  memset(dfn, 0, sizeof(dfn));
  memset(low, 0, sizeof(low));
  memset(iscut, 0, sizeof(iscut));
  memset(belong, 0, sizeof(belong));
  memset(bccsz, 0, sizeof(bccsz));
  memset(vis, 0, sizeof(vis));
  top = 0;
  stamp = 0;
  bccno = 0;
  while (!st.empty()) st.pop();
}
void addedge(int u, int v, int idx) {
  edge[top].u = u;
  edge[top].v = v;
  edge[top].idx = idx;
  edge[top].nxt = head[u];
  head[u] = top++;
  edge[top].u = v;
  edge[top].v = u;
  edge[top].idx = idx;
  edge[top].nxt = head[v];
  head[v] = top++;
}
void tarjan(int u, int fa) {
  dfn[u] = low[u] = ++stamp;
  int child = 0;
  for (int i = head[u]; i != -1; i = edge[i].nxt) {
    int v = edge[i].v, cidx = edge[i].idx;
    if (v == fa || vis[i]) continue;
    vis[i] = vis[i ^ 1] = 1;
    st.push(edge[i]);
    if (!dfn[v]) {
      child++;
      tarjan(v, u);
      if (low[v] < low[u]) low[u] = low[v];
      if (low[v] >= dfn[u]) {
        iscut[u] = 1;
        bcc[++bccno].clear();
        do {
          int uu = st.top().u, vv = st.top().v, idx = st.top().idx;
          if (belong[uu] != bccno) belong[uu] = bccno, bccsz[bccno]++;
          if (belong[vv] != bccno) belong[vv] = bccno, bccsz[bccno]++;
          bcc[bccno].push_back(idx);
          if (idx == cidx) {
            st.pop();
            break;
          }
          st.pop();
        } while (!st.empty());
      }
    } else {
      if (dfn[v] < low[u]) low[u] = dfn[v];
    }
  }
  if (u == fa && child <= 1) iscut[u] = 0;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  init();
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    addedge(u, v, i);
  }
  for (int i = 1; i <= n; i++)
    if (!dfn[i]) tarjan(i, i);
  vector<int> ans;
  for (int i = 1; i <= bccno; i++) {
    if (bcc[i].size() == bccsz[i]) {
      ans.insert(ans.end(), bcc[i].begin(), bcc[i].end());
    }
  }
  sort(ans.begin(), ans.end());
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i] << ' ';
  }
  cout << endl;
  return 0;
}
