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 low[100001], disc[100001], tim = 0, visited[100001];
vector<int> bridges;
vector<int> ans;
int node, edge;
set<int> lewatin;
void dfsans(int pos) {
  if (visited[pos]) return;
  node++;
  edge += adj[pos].size();
  visited[pos] = true;
  for (int temp = 0; temp < adj[pos].size(); temp++) {
    int thenode = adj[pos][temp].first, edgenum = adj[pos][temp].second;
    lewatin.insert(edgenum);
    dfsans(thenode);
  }
}
void dfs(int pos, int par) {
  low[pos] = disc[pos] = tim++;
  visited[pos] = true;
  for (int temp = 0; temp < adj[pos].size(); temp++) {
    int thenode = adj[pos][temp].first, edgenum = adj[pos][temp].second;
    if (thenode == par) continue;
    if (!visited[thenode]) {
      dfs(thenode, pos);
      low[pos] = min(low[pos], low[thenode]);
    } else {
      low[pos] = min(low[pos], disc[thenode]);
    }
    if (low[thenode] > disc[pos]) {
      bridges.push_back(edgenum);
    }
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  int temp, temp2;
  vector<pair<int, int>> edges;
  for (temp = 0; temp < m; temp++) {
    int x, y;
    cin >> x >> y;
    edges.push_back({x, y});
    adj[x].push_back({y, temp});
    adj[y].push_back({x, temp});
  }
  for (temp = 1; temp <= n; temp++) {
    if (!visited[temp]) dfs(temp, temp);
  }
  int curind = 0;
  adj.clear();
  adj.resize(n + 1);
  for (temp = 0; temp < m; temp++) {
    if ((curind < bridges.size()) && (temp == bridges[curind])) {
      curind++;
      continue;
    }
    int x = edges[temp].first, y = edges[temp].second;
    adj[x].push_back({y, temp});
    adj[y].push_back({x, temp});
  }
  memset(visited, 0, sizeof(visited));
  for (temp = 1; temp <= n; temp++) {
    node = 0;
    edge = 0;
    lewatin.clear();
    dfsans(temp);
    edge /= 2;
    if (node == edge) {
      while (lewatin.size() > 0) {
        ans.push_back(*lewatin.begin());
        lewatin.erase(lewatin.begin());
      }
    }
  }
  cout << ans.size() << "\n";
  sort(ans.begin(), ans.end());
  for (temp = 0; temp < ans.size(); temp++) {
    cout << ans[temp] + 1;
    if (temp != ans.size() - 1) cout << " ";
  }
  cout << "\n";
}
