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>
const uint32_t INF = 1e9;
struct Vertex;
struct Edge {
  Vertex *to;
  uint32_t ind;
  Edge(Vertex *pTo = nullptr, uint32_t pInd = INF) : to(pTo), ind(pInd) {}
};
std::vector<uint32_t> ans;
struct Vertex {
  std::vector<Edge> edges;
  Edge par;
  uint32_t depth;
  uint32_t loopCnt;
  uint32_t loopSum;
  uint32_t dLoop;
  Vertex() : par(nullptr), depth(INF), loopCnt(0), loopSum(0), dLoop(0) {}
  void dfs() {
    for (Edge &e : edges) {
      if (e.to == par.to) {
        continue;
      }
      if (e.to->depth == INF) {
        e.to->depth = depth + 1;
        e.to->par = Edge(this, e.ind);
        e.to->dfs();
        loopCnt += e.to->loopCnt;
      } else if (e.to->depth < depth) {
        loopCnt++;
        e.to->loopCnt--;
      }
    }
  }
  void calc_loop_sum() {
    if (par.to != nullptr) {
      loopSum = par.to->loopCnt;
    }
    loopSum += loopCnt;
    for (Edge &e : edges) {
      if (e.to->par.to == this) {
        e.to->calc_loop_sum();
      }
    }
  }
  void determine_loops() {
    for (Edge &e : edges) {
      if (e.to == par.to) {
        continue;
      } else if (e.to->par.to == this) {
        e.to->determine_loops();
        dLoop += e.to->dLoop;
      } else if (e.to->depth < depth) {
        uint32_t edgeCnt = depth - e.to->depth;
        uint32_t crossedCnt = loopSum - e.to->loopSum;
        if (crossedCnt > edgeCnt) {
          dLoop++;
          e.to->dLoop--;
        } else {
          ans.push_back(e.ind);
        }
      }
    }
  }
  void determine_tree_edges() {
    if ((dLoop == 0) && (par.to != nullptr) && (loopCnt > 0)) {
      ans.push_back(par.ind);
    }
    for (Edge &e : edges) {
      if (e.to->par.to == this) {
        e.to->determine_tree_edges();
      }
    }
  }
  uint32_t ind();
};
std::vector<Vertex> graph;
uint32_t Vertex::ind() { return this - &graph[0] + 1; }
void input() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  uint32_t vCnt, eCnt;
  std::cin >> vCnt >> eCnt;
  graph.resize(vCnt);
  for (uint32_t i = 0; i < eCnt; i++) {
    uint32_t a, b;
    std::cin >> a >> b;
    a--;
    b--;
    graph[a].edges.push_back(Edge(&graph[b], i + 1));
    graph[b].edges.push_back(Edge(&graph[a], i + 1));
  }
}
template <class T>
std::ostream &operator<<(std::ostream &s, const std::vector<T> &v) {
  for (const T &i : v) {
    s << i << " ";
  }
  return s;
}
int main() {
  input();
  graph[0].depth = 0;
  graph[0].dfs();
  graph[0].calc_loop_sum();
  graph[0].determine_loops();
  graph[0].determine_tree_edges();
  std::cout << ans.size() << "\n" << ans << "\n";
}
