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 = 1e6 + 7;
vector<pair<pair<int, int>, int> > son[N];
vector<int> bcc_node[N], bcc_edge[N], ans;
stack<pair<pair<int, int>, int> > s;
vector<int> node;
int bcc_cnt, belong[N], is_cnt[N], now_time, tin[N], low[N];
void dfs(int o, int fa) {
  tin[o] = low[o] = ++now_time;
  int ch = 0;
  for (int i = 0; i < son[o].size(); ++i) {
    int v = son[o][i].first.first;
    if (v == fa) continue;
    pair<pair<int, int>, int> edge = {{o, v}, son[o][i].second};
    if (!tin[v]) {
      s.push(edge);
      dfs(v, o);
      low[o] = min(low[o], low[v]);
      if (low[v] >= tin[o]) {
        ch++;
        is_cnt[o] = true;
        bcc_node[++bcc_cnt].clear();
        bcc_edge[bcc_cnt].clear();
        while (true) {
          pair<pair<int, int>, int> now = s.top();
          s.pop();
          bcc_edge[bcc_cnt].push_back(now.second);
          if (belong[now.first.first] != bcc_cnt) {
            belong[now.first.first] = bcc_cnt;
            bcc_node[bcc_cnt].push_back(now.first.first);
          }
          if (belong[now.first.second] != bcc_cnt) {
            belong[now.first.second] = bcc_cnt;
            bcc_node[bcc_cnt].push_back(now.first.second);
          }
          if (now.first.first == o && now.first.second == v) break;
        }
      }
    } else if (tin[v] < tin[o]) {
      s.push(edge);
      low[o] = min(tin[v], low[o]);
    }
  }
  if (!fa && ch == 1) is_cnt[o] = false;
}
int main() {
  int n, m, u, v;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &u, &v);
    son[u].push_back({{v, u}, i});
    son[v].push_back({{u, v}, i});
  }
  for (int i = 1; i <= n; i++) dfs(i, i);
  for (int i = 1; i <= bcc_cnt; i++)
    if (bcc_node[i].size() == bcc_edge[i].size()) {
      for (auto v : bcc_edge[i]) node.push_back(v);
    }
  cout << node.size() << endl;
  sort(node.begin(), node.end());
  for (int i = 0; i < node.size(); i++) cout << node[i] << ' ';
  cout << endl;
  return 0;
}
