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;
int n, m;
vector<pair<int, int> > adj[100005];
int vn, sn;
int l[100005], v[100005];
bool trip[100005], chk[100005];
int cv[100005];
vector<int> ce[100005];
map<pair<int, int>, int> mp;
void dfs(int now, int par) {
  l[now] = v[now] = vn++;
  for (auto &e : adj[now]) {
    int there = e.first;
    if (there == par) continue;
    if (v[there] == -1) {
      dfs(there, now);
      l[now] = min(l[now], l[there]);
    } else
      l[now] = min(l[now], v[there]);
  }
}
void col(int now, int par, int c) {
  if (c >= 0) cv[c]++;
  trip[now] = true;
  for (auto &e : adj[now]) {
    int there = e.first;
    if (there == par) continue;
    if (trip[there]) {
      if (!chk[e.second]) {
        ce[c].push_back(e.second);
        chk[e.second] = true;
      }
      continue;
    }
    if (v[now] <= l[there]) {
      cv[sn]++;
      ce[sn].push_back(e.second);
      chk[e.second] = true;
      col(there, now, sn++);
    } else {
      ce[c].push_back(e.second);
      chk[e.second] = true;
      col(there, now, c);
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    adj[a].emplace_back(b, i + 1);
    adj[b].emplace_back(a, i + 1);
  }
  memset(v, -1, sizeof(v));
  for (int i = 1; i <= n; i++)
    if (v[i] == -1) dfs(i, 0);
  for (int i = 1; i <= n; i++)
    if (!trip[i]) col(i, 0, -1);
  vector<int> ans;
  for (int i = 0; i < sn; i++) {
    if (cv[i] == ce[i].size()) {
      for (auto x : ce[i]) ans.push_back(x);
    }
  }
  sort(ans.begin(), ans.end());
  ans.erase(unique(ans.begin(), ans.end()), ans.end());
  printf("%d\n", ans.size());
  for (auto x : ans) printf("%d ", x);
  printf("\n");
  return 0;
}
