#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<pair<int, int> > adj[100005];
int vn, sn;
int l[100005], v[100005];
bool trip[100005], chk[100005];
int cv[100005];
vector<int> ce[100005];
map<pair<int, int>, int> mp;
void dfs(int now, int par) {
  l[now] = v[now] = vn++;
  for (auto &e : adj[now]) {
    int there = e.first;
    if (there == par) continue;
    if (v[there] == -1) {
      dfs(there, now);
      l[now] = min(l[now], l[there]);
    } else
      l[now] = min(l[now], v[there]);
  }
}
void col(int now, int par, int c) {
  if (c >= 0) cv[c]++;
  trip[now] = true;
  for (auto &e : adj[now]) {
    int there = e.first;
    if (there == par) continue;
    if (trip[there]) {
      if (!chk[e.second]) {
        ce[c].push_back(e.second);
        chk[e.second] = true;
      }
      continue;
    }
    if (v[now] <= l[there]) {
      cv[sn]++;
      ce[sn].push_back(e.second);
      chk[e.second] = true;
      col(there, now, sn++);
    } else {
      ce[c].push_back(e.second);
      chk[e.second] = true;
      col(there, now, c);
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    adj[a].emplace_back(b, i + 1);
    adj[b].emplace_back(a, i + 1);
  }
  memset(v, -1, sizeof(v));
  for (int i = 1; i <= n; i++)
    if (v[i] == -1) dfs(i, 0);
  for (int i = 1; i <= n; i++)
    if (!trip[i]) col(i, 0, -1);
  vector<int> ans;
  for (int i = 0; i < sn; i++) {
    if (cv[i] == ce[i].size()) {
      for (auto x : ce[i]) ans.push_back(x);
    }
  }
  sort(ans.begin(), ans.end());
  ans.erase(unique(ans.begin(), ans.end()), ans.end());
  printf("%d\n", ans.size());
  for (auto x : ans) printf("%d ", x);
  printf("\n");
  return 0;
}
