#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1000000007;
const long long BIG = 1446803456761533460;
const int Big = 336860180;
stringstream sss;
const long long int maxn = 100010;
const long long int maxnlg = 18;
long long int n, m;
vector<pair<long long int, long long int> > g[maxn];
long long int pars[maxnlg][maxn], be[maxnlg][maxn], edown[maxn], ht[maxn],
    invalid[maxn];
long long int vis[maxn];
void dfs1(long long int x, long long int par) {
  vis[x] = 1;
  for (auto y : g[x]) {
    long long int v, e;
    tie(v, e) = y;
    if (!vis[v]) {
      edown[e] = v;
      ht[v] = ht[x] + 1;
      dfs1(v, x);
      be[0][x] += be[0][v];
    } else if (v != par && ht[v] < ht[x]) {
      edown[e] = x;
      ++be[0][x];
      --be[0][v];
    }
  }
}
long long int get_max(long long int a, long long int b) {
  long long int dh = ht[a] - ht[b];
  long long int mx = 0;
  for (long long int i = (0); i < (maxnlg); ++i) {
    if (dh >> i & 1) mx = max(mx, (be[i][a])), a = pars[i][a];
  }
  return mx;
}
void dfs2(long long int x, long long int par) {
  vis[x] = 2;
  pars[0][x] = par;
  for (long long int i = (0); i < (maxnlg - 1); ++i) {
    pars[i + 1][x] = pars[i][pars[i][x]];
    be[i + 1][x] = max(be[i][x], be[i][pars[i][x]]);
  }
  for (auto y : g[x]) {
    long long int v, e;
    tie(v, e) = y;
    if (vis[v] == 1) {
      dfs2(v, x);
      invalid[x] += invalid[v];
    } else if (v != par && ht[v] < ht[x]) {
      if (get_max(x, v) > 1) {
        ++invalid[x];
        --invalid[v];
      }
    }
  }
}
void MAIN() {
  cin >> n >> m;
  for (long long int i = (0); i < (m); ++i) {
    long long int a, b;
    cin >> a >> b;
    --a, --b;
    g[a].emplace_back(b, i), g[b].emplace_back(a, i);
  }
  for (long long int i = (0); i < (n); ++i) {
    if (vis[i] == 0) {
      dfs1(i, i);
      dfs2(i, i);
    }
  }
  vector<long long int> res;
  for (long long int i = (0); i < (m); ++i) {
    if (!invalid[edown[i]] && be[0][edown[i]] == 1) res.emplace_back(i);
  }
  cout << res.size() << '\n';
  for (auto e : res) cout << e + 1 << ' ';
  cout << '\n';
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(10);
  sss << R"(
5 6
1 2
2 3
2 4
4 3
2 5
5 3
6 7
2 3
3 4
4 2
1 2
1 5
5 6
6 1
    )";
  MAIN();
  return 0;
}
