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 = 100100;
const int M = 100100;
namespace BCC {
int vcompNum, ecompNum, I, m;
int first[N], low[N], vis[N], ecomp[N];
int nxt[2 * M], ep[2 * M], vcomp[2 * M];
stack<int> edges, verts;
void init() {
  m = 0;
  memset(first, -1, sizeof(first));
}
void add_edge(int a, int b) {
  nxt[m] = first[ep[m] = a], first[ep[m]] = m, ++m;
  nxt[m] = first[ep[m] = b], first[ep[m]] = m;
  ++m;
}
void biconnected(int u, int par) {
  int v, E;
  low[u] = vis[u] = ++I;
  verts.push(u);
  for (int e = first[u]; e != -1; e = nxt[e]) {
    v = ep[e ^ 1];
    if (!vis[v]) {
      edges.push(e);
      biconnected(v, e);
      low[u] = min(low[u], low[v]);
      if (vis[u] <= low[v]) {
        do {
          E = edges.top();
          edges.pop();
          vcomp[E] = vcomp[E ^ 1] = vcompNum;
        } while (e != E && e != (E ^ 1));
        ++vcompNum;
      }
    } else if (vis[v] < vis[u] && e != (par ^ 1)) {
      low[u] = min(low[u], vis[v]);
      edges.push(e);
    } else if (v == u)
      vcomp[e] = vcomp[e ^ 1] = vcompNum++;
  }
  if (vis[u] <= low[u]) {
    do {
      v = verts.top();
      verts.pop();
      ecomp[v] = ecompNum;
    } while (v != u);
    ++ecompNum;
  }
}
void get_bcc(int n) {
  memset(vis, 0, sizeof vis);
  vcompNum = ecompNum = I = 0;
  for (int i = 0; i < n; ++i)
    if (!vis[i]) biconnected(i, -1);
}
bool isCutVertex(int u) {
  for (int e = first[u]; e != -1; e = nxt[e])
    if (vcomp[e] != vcomp[first[u]]) return true;
  return false;
}
bool isCutEdge(int e) { return ecomp[ep[e]] != ecomp[ep[e ^ 1]]; }
}  // namespace BCC
int ecount[N];
int esz[N];
unordered_set<int> cont[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  BCC::init();
  vector<pair<int, int>> e;
  for (int i = 1; i <= m; ++i) {
    int a, b;
    cin >> a >> b;
    e.emplace_back(a, b);
    BCC::add_edge(a, b);
  }
  BCC::get_bcc(n + 1);
  for (int i = 0; i < m * 2; i += 2) {
    ++esz[BCC::vcomp[i]];
    cont[BCC::vcomp[i]].insert(e[i / 2].first);
    cont[BCC::vcomp[i]].insert(e[i / 2].second);
  }
  for (int i = 0; i < BCC::vcompNum; ++i) {
    ecount[i] = cont[i].size();
  }
  vector<int> g;
  for (int i = 0; i < m; ++i) {
    auto [a, b] = e[i];
    if (ecount[BCC::vcomp[i * 2]] == esz[BCC::vcomp[i * 2]]) {
      g.push_back(i + 1);
    }
  }
  cout << g.size() << endl;
  for (auto& x : g) {
    cout << x << " ";
  }
  cout << endl;
  return 0;
}
