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 int mod = (int)1e9 + 7;
const int maxn = 1e6 + 88;
const int inf = 1e9 + 88;
const int logn = 22;
const int maxa = 3e6 + 88;
const int block = 775;
const long long infll = 1e18 + 88;
const char sgl[5] = {'a', 'e', 'i', 'o', 'u'};
const int dx[] = {-1, 1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const int knightx[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int knighty[] = {-1, 1, -2, 2, -2, 2, -1, 1};
const int kingx[] = {-1, -1, -1, 0, 0, 1, 1, 1};
const int kingy[] = {-1, 0, 1, -1, 1, -1, 0, 1};
const char sep = 'a' - 1;
const double eps = 1e-9;
const int maxn1 = 1e3 + 88;
bool used[maxn], is[maxn];
int p[maxn], pe[maxn], circle[maxn], st[maxn], fn[maxn], edge[maxn], tin[maxn];
vector<pair<int, int> > g[maxn];
vector<int> ans;
int timer, t;
void dfs(int v, int pr, int no) {
  tin[v] = t++;
  used[v] = true;
  circle[v] = -1;
  p[v] = pr;
  pe[v] = no;
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i].first;
    if (to == pr) continue;
    if (used[to]) {
      if (tin[to] > tin[v]) continue;
      edge[timer] = g[v][i].second;
      st[timer] = v;
      fn[timer] = to;
      if (circle[v] != -1) {
        is[circle[v]] = true;
        is[timer] = true;
      } else
        circle[v] = timer;
      timer++;
      continue;
    }
    dfs(to, v, g[v][i].second);
    if (circle[to] != -1 && !is[circle[to]] && fn[circle[to]] != v)
      if (circle[v] != -1) {
        is[circle[v]] = true;
        is[circle[to]] = true;
      } else
        circle[v] = circle[to];
  }
}
bool solve() {
  ios_base::sync_with_stdio(0);
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m, i, v, u;
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    cin >> v >> u;
    v--, u--;
    g[v].push_back({u, i});
    g[u].push_back({v, i});
  }
  dfs(0, 0, 0);
  for (i = 0; i < timer; i++)
    if (!is[i]) {
      ans.push_back(edge[i]);
      int cur = st[i];
      while (cur != fn[i]) {
        ans.push_back(pe[cur]);
        cur = p[cur];
      }
    }
  sort(ans.begin(), ans.end());
  cout << ans.size() << "\n";
  for (i = 0; i < ans.size(); i++) cout << ans[i] + 1 << " ";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
