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 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]) {
      invalid[x] = get_max(x, v) > 1;
    }
  }
}
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;
}
