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 inf = 0x3f3f3f3f;
const int inf_ = 0x7fffffff;
const long long inff = 4557430888798830399ll;
const double pi = acos(-1.0);
long long mod = 1e9 + 7;
unordered_map<int, int> id[100005];
struct DCC {
  DCC() { init(0, 0); }
  int n, t, h, m, dfn[100005], low[100005], s[100005], e[100005];
  pair<int, int> g[100005];
  vector<int>*N, cut, D[100005];
  vector<pair<int, int> > F[100005];
  void init(int _n, vector<int>* _N) {
    n = _n;
    N = _N;
    t = h = -1;
    m = 0;
    memset(dfn, 0, sizeof(dfn));
    memset(low, 0, sizeof(low));
    cut.clear();
  }
  void dfs(int u, int d, int p) {
    int sec = 0, son = d > 1;
    dfn[u] = low[u] = d;
    s[++t] = u;
    for (auto v : N[u]) {
      if (v != p) g[++h] = make_pair(u, v);
      if (!dfn[v]) {
        dfs(v, d + 1, u);
        low[u] = min(low[u], low[v]);
        if (low[v] >= dfn[u]) {
          if (++son == 2) cut.push_back(u);
          m += 1;
          D[m].clear();
          D[m].push_back(u);
          F[m].clear();
          do F[m].push_back(g[h]);
          while (g[h--] != make_pair(u, v));
          do D[m].push_back(s[t]);
          while (s[t--] != v);
        }
      } else if (v != p || sec++)
        low[u] = min(low[u], dfn[v]);
    }
  }
  void run() {
    for (int i = (1); i <= (n); ++i)
      if (!dfn[i]) dfs(i, 1, 0);
    gen();
  }
  void gen() {
    vector<int> z;
    for (int i = (1); i <= (m); ++i)
      if (((int)F[i].size()) == ((int)D[i].size()) && ((int)D[i].size()) > 2)
        for (auto e : F[i]) z.push_back(id[e.first][e.second]);
    sort((z).begin(), (z).end());
    z.erase(unique((z).begin(), (z).end()), z.end());
    cout << ((int)z.size()) << endl;
    for (int i = (0); i < (((int)z.size())); ++i)
      cout << z[i] << " \n"[i == ((int)z.size()) - 1];
  }
};
vector<int> N[100005];
DCC t;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m, u, v;
  cin >> n >> m;
  for (int i = (1); i <= (m); ++i) {
    cin >> u >> v;
    N[u].push_back(v);
    N[v].push_back(u);
    id[u][v] = id[v][u] = i;
  }
  t.init(n, N);
  t.run();
}
