#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
const int mod = 1e9 + 7;
vector<int> g_bcc[maxn], f, ans;
vector<pair<int, int> > g[maxn];
pair<int, int> edge[maxn];
int pre[maxn], low[maxn], bcc[maxn];
int dfs_t, bcc_cnt;
stack<int> ST;
void dfs(int u, int fa) {
  pre[u] = low[u] = ++dfs_t;
  for (auto vx : g[u]) {
    int v = vx.first;
    if (!pre[v]) {
      ST.push(vx.second);
      dfs(v, u);
      low[u] = min(low[u], low[v]);
      if (low[v] >= pre[u]) {
        g_bcc[++bcc_cnt].clear();
        f.clear();
        while (!ST.empty()) {
          int e = ST.top();
          f.push_back(e);
          ST.pop();
          if (bcc[edge[e].first] != bcc_cnt) {
            g_bcc[bcc_cnt].push_back(edge[e].first);
            bcc[edge[e].first] = bcc_cnt;
          }
          if (bcc[edge[e].second] != bcc_cnt) {
            g_bcc[bcc_cnt].push_back(edge[e].second);
            bcc[edge[e].second] = bcc_cnt;
          }
          if (e == vx.second) break;
        }
        if (f.size() == g_bcc[bcc_cnt].size()) {
          for (auto x : f) ans.push_back(x);
        }
      }
    } else if (pre[v] < pre[u] && v != fa) {
      ST.push(vx.second);
      low[u] = min(low[u], pre[v]);
    }
  }
}
int main() {
  int n, m, i, u, v;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= m; i++) {
    scanf("%d%d", &u, &v);
    g[u].push_back(pair<int, int>(v, i));
    g[v].push_back(pair<int, int>(u, i));
    edge[i] = pair<int, int>(u, v);
  }
  for (i = 1; i <= n; i++) {
    if (!pre[i]) dfs(i, 0);
  }
  sort(ans.begin(), ans.end());
  printf("%d\n", (int)ans.size());
  for (auto x : ans) printf("%d ", x);
  puts("");
  return 0;
}
