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>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
template <class T>
inline bool setmin(T &a, T b) {
  if (a > b) return a = b, 1;
  return 0;
}
template <class T>
inline bool setmax(T &a, T b) {
  if (a < b) return a = b, 1;
  return 0;
}
template <class T>
inline T fast(T a, T b, T mod) {
  long long res = 1;
  while (b) {
    if (b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return res;
}
template <class T>
istream &operator>>(istream &os, vector<T> &container) {
  for (auto &u : container) os >> u;
  return os;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &container) {
  for (auto &u : container) os << u << " ";
  return os;
}
template <class T>
inline T gcd(T a, T b) {
  while (b) swap(a %= b, b);
  return abs(a);
}
const long long INF = 1e9 + 7;
const long long mod = 998244353;
const long long BIG_INF = 1e18 + 7;
const long long N = 1e6 + 7;
const long long T = 1 << 20;
const long double inf = 1e18;
long long m, n, k, q;
long long roz[N];
long long rep[N];
long long odw[N];
long long preorder[N];
vector<vector<pair<long long, long long> > > G(N);
long long cnt;
vector<long long> ans;
long long Find(long long x) {
  return (x == rep[x] ? x : rep[x] = Find(rep[x]));
}
void Union(long long a, long long b) {
  assert(a and b);
  a = Find(a);
  b = Find(b);
  if (a == b) return;
  roz[b] += roz[a];
  rep[a] = b;
}
pair<long long, long long> lepszy(pair<long long, long long> a,
                                  pair<long long, long long> b) {
  return (a.first < b.first ? a : b);
}
void polacz(pair<long long, long long> &najw, pair<long long, long long> temp,
            long long v) {
  if (temp.first == preorder[v] or temp.first == INF) return;
  if (najw.first == INF) {
    najw = temp;
    return;
  }
  Union(najw.second, temp.second);
  najw = lepszy(najw, temp);
}
pair<long long, long long> dfs(long long x, long long przodek = -1) {
  odw[x] = 1;
  preorder[x] = cnt++;
  pair<long long, long long> najwyzszy = {INF, 0};
  vector<pair<long long, long long> > nad;
  for (auto &u : G[x])
    if (odw[u.first] and u.first != przodek)
      nad.push_back({preorder[u.first], u.second});
  for (auto &u : G[x])
    if (!odw[u.first]) polacz(najwyzszy, dfs(u.first, x), x);
  for (auto &u : nad) polacz(najwyzszy, u, x);
  return najwyzszy;
}
pair<long long, long long> dfs2(long long x, long long przodek = -1,
                                long long nr = -1) {
  odw[x] = 1;
  pair<long long, long long> najwyzszy = {INF, 0};
  vector<pair<long long, long long> > nad;
  for (auto &u : G[x])
    if (odw[u.first] and u.first != przodek)
      nad.push_back({preorder[u.first], u.second});
  for (auto &u : G[x])
    if (!odw[u.first]) polacz(najwyzszy, dfs2(u.first, x, u.second), x);
  for (auto &u : nad) polacz(najwyzszy, u, x);
  if (nr != -1 and najwyzszy.first != INF and
      roz[Find(najwyzszy.second)] == 1) {
    ans.push_back(nr);
    ans.push_back(najwyzszy.second);
  }
  return najwyzszy;
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (long long i = 0; i < (m + 2); i++) {
    rep[i] = i;
    roz[i] = 1;
  }
  for (long long i = 0; i < (m); i++) {
    long long a, b;
    cin >> a >> b;
    G[a].push_back({b, i + 1});
    G[b].push_back({a, i + 1});
  }
  for (long long i = 1; i <= n; i++)
    if (!odw[i]) dfs(i);
  fill(odw, odw + N, 0);
  for (long long i = 1; i <= n; i++)
    if (!odw[i]) dfs2(i);
  sort((ans).begin(), (ans).end());
  ans.resize(unique((ans).begin(), (ans).end()) - ans.begin());
  cout << (long long)(ans).size() << '\n' << ans << '\n';
}
