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 long long mod = 1e9 + 7;
const long long maxn = 1e5 + 7;
const long long maxm = 2e5 + 7;
int low[maxn], tin[maxn], head[maxm], bel[maxn];
int cnt = 0, times = 0, totn = 0;
stack<int> sk;
set<int> bcc[maxn];
set<int> sz[maxn];
struct EDGE {
  int to, next;
} p[maxm * 2];
struct Edge {
  int u, v, id;
};
map<int, Edge> mmp;
stack<Edge> Skeg;
void add(int u, int v) {
  p[cnt].to = v;
  p[cnt].next = head[u];
  head[u] = cnt++;
}
void tarjan(int k, int fa) {
  low[k] = tin[k] = ++times;
  int v, child = 0;
  Edge t;
  for (int i = head[k]; i != -1; i = p[i].next) {
    v = p[i].to;
    if (v == fa) continue;
    Edge e = (Edge){k, v, i};
    if (!tin[v]) {
      Skeg.push(e);
      child++;
      tarjan(v, k);
      low[k] = min(low[k], low[v]);
      if (low[v] >= tin[k]) {
        totn++;
        do {
          t = Skeg.top();
          Skeg.pop();
          sz[totn].insert(t.id);
          if (bel[t.u] != totn) {
            bcc[totn].insert(t.u);
            bel[t.u] = totn;
          }
          if (bel[t.v] != totn) {
            bcc[totn].insert(t.v);
            bel[t.v] = totn;
          }
        } while (t.v != v && t.u != k);
      }
    } else if (tin[v] < tin[k] && v != fa) {
      Skeg.push(e);
      low[k] = min(low[k], tin[v]);
    }
  }
}
int main() {
  memset(head, -1, sizeof(head));
  int n, m, u, v;
  scanf("%d", &n);
  scanf("%d", &m);
  for (register int i = 1; i <= m; i = i + 1) {
    scanf("%d", &u);
    scanf("%d", &v);
    add(u, v);
    add(v, u);
    Edge tem = {u, v};
    mmp[i] = tem;
  }
  for (register int i = 1; i <= n; i = i + 1) {
    if (!tin[i]) tarjan(i, -1);
  }
  set<int> ans;
  for (register int i = 1; i <= totn; i = i + 1) {
    if (bcc[i].size() == sz[i].size()) {
      for (auto j : sz[i]) ans.insert(j & 1 ? (j + 1) / 2 : (j + 2) / 2);
    }
  }
  printf("%d", ans.size());
  printf("\n");
  ;
  for (set<int>::iterator it = ans.begin(); it != ans.end(); it++) {
    if (it != ans.begin()) printf("%s", " ");
    printf("%d", *it);
  }
  return 0;
}
