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;
vector<vector<pair<int, int>>> adj(100001);
int disc[100001], low[100001], tim;
struct edge {
  int x, y, ind;
};
vector<edge> s;
vector<int> ans;
void proses(vector<edge> &v) {
  set<int> s;
  int temp;
  for (int temp = 0; temp < v.size(); temp++) {
    s.insert(v[temp].x);
    s.insert(v[temp].y);
  }
  if (s.size() == v.size()) {
    for (temp = 0; temp < v.size(); temp++) {
      ans.push_back(v[temp].ind);
    }
  }
}
void dfs(int pos, int par) {
  disc[pos] = low[pos] = tim++;
  int child = 0;
  for (int temp = 0; temp < adj[pos].size(); temp++) {
    int thenode = adj[pos][temp].first, ind = adj[pos][temp].second;
    if ((thenode == par) ||
        ((disc[thenode] != -1) && (disc[thenode] > disc[pos])))
      continue;
    if (disc[thenode] == -1) {
      s.push_back({pos, thenode, ind});
      dfs(thenode, pos);
      child++;
      low[pos] = min(low[pos], low[thenode]);
    } else {
      s.push_back({pos, thenode, ind});
      low[pos] = min(low[pos], disc[thenode]);
    }
    if (((pos == par) && (child > 1)) ||
        ((pos != par) && (disc[pos] <= low[thenode]))) {
      vector<edge> edges;
      while (true) {
        int u = s.back().x, v = s.back().y, ind = s.back().ind;
        edges.push_back({u, v, ind});
        s.pop_back();
        if ((u == pos) && (v == thenode)) break;
      }
      proses(edges);
    }
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  int temp, temp2;
  for (temp = 1; temp <= m; temp++) {
    int x, y;
    cin >> x >> y;
    adj[x].push_back({y, temp});
    adj[y].push_back({x, temp});
  }
  memset(disc, -1, sizeof(disc));
  for (temp = 1; temp <= n; temp++) {
    if (disc[temp] == -1) {
      dfs(temp, temp);
      proses(s);
      s.clear();
    }
  }
  sort(ans.begin(), ans.end());
  cout << ans.size() << "\n";
  for (temp = 0; temp < ans.size(); temp++) {
    cout << ans[temp];
    if (temp != ans.size() - 1) cout << " ";
  }
  cout << "\n";
}
