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 N = 2e5 + 10;
int g[N], v[N << 1], nxt[N << 1], ed;
int dfn[N], low[N], q[N], cut[N], t, sub, num;
int al;
void add(int x, int y) { v[++ed] = y, nxt[ed] = g[x], g[x] = ed; }
vector<int> scc[N];
void ADD(int id, int x) { scc[id].push_back(x); }
map<pair<int, int>, int> mp;
set<int> s;
void tarjan(int x, int f) {
  dfn[x] = low[x] = ++num, q[++t] = x;
  for (int i = g[x]; i; i = nxt[i])
    if (!dfn[v[i]]) {
      int y = v[i];
      tarjan(y, x);
      if (low[x] > low[y]) low[x] = low[y];
      if (!f) sub++;
      if (dfn[x] <= low[y] && f || !f && sub > 1) {
        cut[x] = 1;
        s.clear();
        ADD(++al, x);
        s.insert(x);
        while (1) {
          int z = q[t--];
          ADD(al, z);
          for (int j = g[z]; j; j = nxt[j]) {
            int to = v[j];
            if (s.count(to)) {
              if (to < z)
                mp[{to, z}] = al;
              else
                mp[{z, to}] = al;
            }
          }
          s.insert(z);
          if (z == y) break;
        }
      }
    } else if (low[x] > dfn[v[i]])
      low[x] = dfn[v[i]];
}
pair<int, int> e[N];
int cnt[N], vis[N];
int main() {
  std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1, x, y; i <= m; i++) {
    cin >> x >> y;
    e[i].first = x;
    e[i].second = y;
    add(x, y);
    add(y, x);
  }
  for (int i = 1; i <= n; i++)
    if (!dfn[i]) {
      sub = 0, tarjan(i, 0);
      if (t) {
        al++;
        s.clear();
        while (t) {
          int x = q[t];
          ADD(al, q[t--]);
          for (int j = g[x]; j; j = nxt[j]) {
            int to = v[j];
            if (s.count(to)) {
              if (x < to)
                mp[{x, to}] = al;
              else
                mp[{to, x}] = al;
            }
          }
          s.insert(x);
        }
      }
    }
  for (int i = 1; i <= m; i++) {
    int x = e[i].first, y = e[i].second;
    if (x > y) swap(x, y);
    cnt[mp[{x, y}]]++;
  }
  vector<int> res;
  for (int i = 1; i <= m; i++) {
    int x = e[i].first, y = e[i].second;
    if (y < x) swap(x, y);
    int sc = mp[{x, y}];
    if (cnt[sc] == (int)scc[sc].size()) res.push_back(i);
  }
  cout << (int)res.size() << '\n';
  for (int it : res) cout << it << ' ';
  return 0;
}
