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 = 1e5;
int depth[N];
int mindepth[N];
int col[N];
bool is[N];
bool mark[N];
vector<pair<int, int>> g[N];
int colors = 0;
void findPoints(int v, int d = 0, int p = -1) {
  mark[v] = true;
  mindepth[v] = depth[v] = d;
  int childs = 0;
  for (auto to : g[v]) {
    int u = to.first;
    int id = to.second;
    if (mark[u]) {
      mindepth[v] = min(mindepth[v], depth[u]);
    } else {
      ++childs;
      findPoints(u, d + 1);
      mindepth[v] = min(mindepth[v], mindepth[u]);
      if (mindepth[u] >= depth[v]) {
        is[v] = true;
        col[id] = colors++;
      }
    }
  }
  if (p == 1 && childs >= 2) {
    is[v] = true;
  }
}
void print(int v, int c = -1) {
  mark[v] = true;
  for (auto to : g[v]) {
    int u = to.first;
    int id = to.second;
    if (!mark[u]) {
      if (col[id] != -1) {
        print(u, col[id]);
      } else if (c != -1) {
        col[id] = c;
        print(u, c);
      }
    } else if (c != -1 && col[id] == -1) {
      col[id] = c;
    }
  }
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    --u, --v;
    g[u].push_back({v, i});
    g[v].push_back({u, i});
  }
  memset(col, -1, sizeof col);
  for (int v = 0; v < n; ++v) {
    if (!mark[v]) {
      findPoints(v, 0, 1);
    }
  }
  memset(mark, false, sizeof mark);
  for (int v = 0; v < n; ++v) {
    if (!mark[v] && is[v]) {
      print(v);
    }
  }
  vector<set<int>> pts(colors);
  vector<set<int>> ed(colors);
  for (int v = 0; v < n; ++v) {
    for (auto to : g[v]) {
      int u = to.first;
      int id = to.second;
      pts[col[id]].insert(u);
      pts[col[id]].insert(v);
      ed[col[id]].insert(id);
    }
  }
  set<int> ans;
  for (int i = 0; i < colors; ++i) {
    if (pts[i].size() == ed[i].size()) {
      ans.insert(ed[i].begin(), ed[i].end());
    }
  }
  printf("%d\n", static_cast<int>(ans.size()));
  for (int v : ans) {
    printf("%d ", v + 1);
  }
  putchar('\n');
}
