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;
template <typename T>
T read1() {
  T t = 0;
  char k;
  bool v = 0;
  do (k = getchar()) == '-' && (v = 1);
  while ('0' > k || k > '9');
  while ('0' <= k && k <= '9')
    t = (t << 3) + (t << 1) + (k ^ '0'), k = getchar();
  return v ? -t : t;
}
int s, m, dfn[100005], low[100005], t, bel[100005], cnt, d[100005], si[100005];
bool cu[100005];
stack<int> sta;
vector<int> G[100005], X[100005];
map<pair<int, int>, int> ma;
vector<int> fr[100005], ans;
void tarjan(int n, int fa) {
  dfn[n] = low[n] = ++t;
  for (int i = 0; i < G[n].size(); ++i)
    if (!dfn[G[n][i]]) {
      sta.push(G[n][i]);
      tarjan(G[n][i], n);
      low[n] = min(low[n], low[G[n][i]]);
      if (low[G[n][i]] >= dfn[n]) {
        ++cnt;
        si[cnt] = 2;
        while (sta.top() != G[n][i])
          bel[sta.top()] = cnt, X[cnt].push_back(sta.top()), sta.pop(),
          ++si[cnt];
        X[cnt].push_back(sta.top()), sta.pop();
        X[cnt].push_back(n);
        bel[G[n][i]] = bel[n] = cnt;
        for (int j = 0; j < X[cnt].size(); ++j)
          for (int k = 0; k < G[X[cnt][j]].size(); ++k)
            if (G[X[cnt][j]][k] < X[cnt][j] && bel[G[X[cnt][j]][k]] == cnt)
              fr[cnt].push_back(ma[make_pair(G[X[cnt][j]][k], X[cnt][j])]);
      }
    } else if (G[n][i] ^ fa)
      low[n] = min(low[n], dfn[G[n][i]]);
}
int main() {
  s = read1<long long>();
  m = read1<long long>();
  for (int i = 1; i <= m; ++i) {
    int u = read1<long long>(), v = read1<long long>();
    G[u].push_back(v);
    G[v].push_back(u);
    ma[make_pair(u, v)] = ma[make_pair(v, u)] = i;
  }
  tarjan(1, 0);
  for (int i = 1; i <= cnt; ++i)
    if (fr[i].size() == si[i])
      ans.insert(ans.end(), fr[i].begin(), fr[i].end());
  sort(ans.begin(), ans.end());
  ans.erase(unique(ans.begin(), ans.end()), ans.end());
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); ++i) cout << ans[i] << ' ';
  return 0;
}
