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 Max = 1e5 + 10;
vector<pair<int, int> > N[Max];
bool seen[Max];
int h[Max];
int q[Max];
int c[Max];
int g[Max];
int good[Max];
void DFS(int v) {
  seen[v] = true;
  for (pair<int, int> u : N[v])
    if (!seen[u.first]) {
      h[u.first] = h[v] + 1;
      DFS(u.first);
    } else if (h[u.first] < h[v] - 1) {
      q[u.first]--;
      q[v]++;
    }
}
void DFS1(int v) {
  seen[v] = true;
  for (pair<int, int> u : N[v])
    if (!seen[u.first]) {
      DFS1(u.first);
      q[v] += q[u.first];
    }
}
void DFS2(int v) {
  seen[v] = true;
  c[v] += q[v] >= 2;
  for (pair<int, int> u : N[v])
    if (!seen[u.first]) {
      c[u.first] += c[v];
      DFS2(u.first);
    }
}
void DFS3(int v) {
  seen[v] = true;
  for (pair<int, int> u : N[v])
    if (!seen[u.first]) {
      DFS3(u.first);
    } else if (h[u.first] < h[v] - 1) {
      int cnt = c[v] - c[u.first];
      if (cnt) {
        good[u.second] = false;
        g[v]++;
        g[u.first]--;
      }
    }
}
void DFS4(int v, int e = 0) {
  seen[v] = true;
  for (pair<int, int> u : N[v])
    if (!seen[u.first]) {
      DFS4(u.first, u.second);
      g[v] += g[u.first];
    }
  if (g[v]) good[e] = false;
}
int DFS5(int v, int e = 0) {
  seen[v] = true;
  int val = 1000000;
  for (pair<int, int> u : N[v])
    if (!seen[u.first]) {
      val = min(DFS5(u.first, u.second), val);
    } else if (h[u.first] < h[v] - 1) {
      val = min(h[u.first], val);
    }
  if (val >= h[v]) good[e] = false;
  return val;
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int a, b;
    cin >> a >> b;
    N[a].push_back(make_pair(b, i));
    N[b].push_back(make_pair(a, i));
  }
  for (int i = 1; i <= m; i++) good[i] = true;
  DFS(1);
  for (int i = 1; i <= n; i++) seen[i] = false;
  DFS1(1);
  for (int i = 1; i <= n; i++) seen[i] = false;
  DFS2(1);
  for (int i = 1; i <= n; i++) seen[i] = false;
  DFS3(1);
  for (int i = 1; i <= n; i++) seen[i] = false;
  DFS4(1);
  for (int i = 1; i <= n; i++) seen[i] = false;
  DFS5(1);
  int cnt = 0;
  for (int i = 1; i <= m; i++) cnt += good[i];
  cout << cnt << '\n';
  for (int i = 1; i <= m; i++)
    if (good[i]) cout << i << " ";
  cout << '\n';
}
