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 T1, typename T2>
inline void chkmin(T1 &x, T2 y) {
  if (x > y) x = y;
}
template <typename T1, typename T2>
inline void chkmax(T1 &x, T2 y) {
  if (x < y) x = y;
}
template <typename T, typename U>
inline ostream &operator<<(ostream &_out, const pair<T, U> &_p) {
  _out << _p.first << ' ' << _p.second;
  return _out;
}
template <typename T, typename U>
inline istream &operator>>(istream &_in, pair<T, U> &_p) {
  _in >> _p.first >> _p.second;
  return _in;
}
template <typename T>
inline ostream &operator<<(ostream &_out, const vector<T> &_v) {
  if (_v.empty()) {
    return _out;
  }
  _out << _v.front();
  for (auto _it = ++_v.begin(); _it != _v.end(); ++_it) {
    _out << ' ' << *_it;
  }
  return _out;
}
template <typename T>
inline istream &operator>>(istream &_in, vector<T> &_v) {
  for (auto &_i : _v) {
    _in >> _i;
  }
  return _in;
}
template <typename T>
inline ostream &operator<<(ostream &_out, const set<T> &_s) {
  if (_s.empty()) {
    return _out;
  }
  _out << *_s.begin();
  for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) {
    _out << ' ' << *_it;
  }
  return _out;
}
template <typename T>
inline ostream &operator<<(ostream &_out, const multiset<T> &_s) {
  if (_s.empty()) {
    return _out;
  }
  _out << *_s.begin();
  for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) {
    _out << ' ' << *_it;
  }
  return _out;
}
template <typename T>
inline ostream &operator<<(ostream &_out, const unordered_set<T> &_s) {
  if (_s.empty()) {
    return _out;
  }
  _out << *_s.begin();
  for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) {
    _out << ' ' << *_it;
  }
  return _out;
}
template <typename T>
inline ostream &operator<<(ostream &_out, const unordered_multiset<T> &_s) {
  if (_s.empty()) {
    return _out;
  }
  _out << *_s.begin();
  for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) {
    _out << ' ' << *_it;
  }
  return _out;
}
template <typename T, typename U>
inline ostream &operator<<(ostream &_out, const map<T, U> &_m) {
  if (_m.empty()) {
    return _out;
  }
  _out << '(' << _m.begin()->first << ": " << _m.begin()->second << ')';
  for (auto _it = ++_m.begin(); _it != _m.end(); ++_it) {
    _out << ", (" << _it->first << ": " << _it->second << ')';
  }
  return _out;
}
template <typename T, typename U>
inline ostream &operator<<(ostream &_out, const unordered_map<T, U> &_m) {
  if (_m.empty()) {
    return _out;
  }
  _out << '(' << _m.begin()->first << ": " << _m.begin()->second << ')';
  for (auto _it = ++_m.begin(); _it != _m.end(); ++_it) {
    _out << ", (" << _it->first << ": " << _it->second << ')';
  }
  return _out;
}
const string FILENAME = "input";
const int MAXN = 100001;
int n, m;
vector<pair<int, int>> g[MAXN];
int tin[MAXN];
int fup[MAXN];
bool used[MAXN];
int tim;
int colour;
void dfs(int v, int p) {
  used[v] = true;
  tin[v] = fup[v] = tim++;
  for (auto h : g[v]) {
    if (h.first == p) {
      continue;
    }
    if (used[h.first]) {
      chkmin(fup[v], tin[h.first]);
    } else {
      dfs(h.first, v);
      chkmin(fup[v], fup[h.first]);
    }
  }
}
set<int> ups[MAXN], downs[MAXN];
void dfs_colour(int v, int p, int cur) {
  used[v] = true;
  for (auto h : g[v]) {
    if (h.first == p) {
      continue;
    }
    if (used[h.first]) {
      if (tin[v] > tin[h.first]) {
        ups[cur].insert(h.second);
        downs[cur].insert(v);
        downs[cur].insert(h.first);
      }
      continue;
    }
    if (fup[h.first] >= tin[v]) {
      colour++;
      ups[colour - 1].insert(h.second);
      downs[colour - 1].insert(v);
      downs[colour - 1].insert(h.first);
      dfs_colour(h.first, v, colour - 1);
    } else {
      ups[cur].insert(h.second);
      downs[cur].insert(v);
      downs[cur].insert(h.first);
      dfs_colour(h.first, v, cur);
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    g[a].push_back({b, i + 1});
    g[b].push_back({a, i + 1});
  }
  for (int i = 1; i <= n; i++) {
    if (!used[i]) {
      dfs(i, -1);
    }
  }
  memset(used, 0, sizeof(used));
  for (int i = 1; i <= n; i++) {
    if (!used[i]) {
      colour++;
      dfs_colour(i, -1, colour - 1);
    }
  }
  vector<int> ans;
  for (int i = 0; i < colour; i++) {
    if ((int)(ups[i]).size() == (int)(downs[i]).size()) {
      for (auto x : ups[i]) {
        ans.push_back(x);
      }
    }
  }
  sort((ans).begin(), (ans).end());
  ans.resize(distance(ans.begin(), unique((ans).begin(), (ans).end())));
  cout << (int)(ans).size() << endl;
  for (auto x : ans) {
    cout << x + 1 << ' ';
  }
  cout << endl;
  return 0;
}
