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 limite = 1000000;
int n, m;
vector<pair<int, int> > g[limite], gini[limite];
int visto[limite];
vector<int> sol;
int profant[limite];
int profundidad[limite];
vector<pair<int, int> > a[limite];
void eliminapadre(int u, int p, int prof) {
  visto[u] = 1;
  profundidad[u] = prof;
  vector<pair<int, int> > &ar = g[u];
  vector<pair<int, int> > nextar;
  for (int i = 0; i < int(ar.size()); i++) {
    int v = ar[i].first;
    if (v != p) nextar.push_back(ar[i]);
    if (not visto[v]) {
      a[u].push_back(ar[i]);
      eliminapadre(v, u, prof + 1);
    }
  }
  ar = nextar;
}
void computacomponente(int u, vector<int> &c) {
  if (visto[u]) return;
  visto[u] = 1;
  c.push_back(u);
  vector<pair<int, int> > &ar = a[u];
  for (int i = 0; i < int(ar.size()); i++) computacomponente(ar[i].first, c);
}
int tiempo = 0;
int numcomp[limite];
void computa(int uini, vector<int> lista) {
  tiempo++;
  int n = int(lista.size());
  vector<int> act;
  for (int i = 0; i < int(lista.size()); i++) numcomp[lista[i]] = tiempo;
  for (int i = 0; i < int(lista.size()); i++) {
    int u = lista[i];
    if (u == uini) continue;
    vector<pair<int, int> > &ar = gini[u];
    for (int j = 0; j < int(ar.size()); j++) {
      int v = ar[j].first;
      if (numcomp[v] == tiempo and (v == uini or u < v))
        act.push_back(ar[j].second);
    }
  }
  if (int(act.size()) == n) {
    for (int i = 0; i < int(act.size()); i++) sol.push_back(act[i]);
  }
}
void calcula(int u) {
  profant[u] = profundidad[u];
  {
    vector<pair<int, int> > &ar = a[u];
    for (int i = 0; i < int(ar.size()); i++) {
      int v = ar[i].first;
      calcula(v);
      profant[u] = min(profant[u], profant[v]);
      if (profant[v] == profundidad[u]) {
        vector<int> c;
        c.push_back(u);
        computacomponente(v, c);
        computa(u, c);
      }
    }
  }
  {
    vector<pair<int, int> > &ar = g[u];
    for (int i = 0; i < int(ar.size()); i++) {
      int v = ar[i].first;
      if (profundidad[v] < profundidad[u])
        profant[u] = min(profant[u], profundidad[v]);
    }
  }
  if (profant[u] == profundidad[u]) visto[u] = 1;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(pair<int, int>(v, i));
    g[v].push_back(pair<int, int>(u, i));
    gini[u].push_back(pair<int, int>(v, i));
    gini[v].push_back(pair<int, int>(u, i));
  }
  for (int u = 1; u <= n; u++)
    if (not visto[u]) eliminapadre(u, 0, 0);
  for (int u = 1; u <= n; u++) visto[u] = 0;
  for (int u = 1; u <= n; u++)
    if (not visto[u]) calcula(u);
  sort(sol.begin(), sol.end());
  cout << int(sol.size()) << endl;
  for (int i = 0; i < int(sol.size()); i++) {
    if (i > 0) cout << " ";
    cout << sol[i];
  }
  cout << endl;
}
