#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 20;
int pre[maxn];
int iscut[maxn];
int bccno[maxn];
int dfs_clock;
int bcc_cnt;
map<pair<int, int>, int> E;
vector<int> G[maxn];
vector<int> bcc[maxn];
vector<int> SW;
vector<pair<int, int>> K;
stack<pair<int, int>> S;
int dfs(int u, int fa) {
  int lowu = pre[u] = ++dfs_clock;
  int child = 0;
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i];
    pair<int, int> e = make_pair(u, v);
    if (!pre[v]) {
      S.push(e);
      child++;
      int lowv = dfs(v, u);
      lowu = min(lowv, lowu);
      if (lowv >= pre[u]) {
        iscut[u] = true;
        bcc_cnt++;
        bcc[bcc_cnt].clear();
        int num1 = 0;
        int num2 = 0;
        vector<pair<int, int>> Z;
        for (;;) {
          pair<int, int> x = S.top();
          S.pop();
          Z.push_back(x);
          num2++;
          if (bccno[x.first] != bcc_cnt) {
            bcc[bcc_cnt].push_back(x.first);
            bccno[x.first] = bcc_cnt;
            num1++;
          }
          if (bccno[x.second] != bcc_cnt) {
            bcc[bcc_cnt].push_back(x.second);
            bccno[x.second] = bcc_cnt;
            num1++;
          }
          if (x.first == u && x.second == v) break;
        }
        if (num1 == num2) {
          for (int w = 0; w < Z.size(); w++) {
            SW.push_back(E[make_pair(min(Z[w].first, Z[w].second),
                                     max(Z[w].first, Z[w].second))]);
          }
        }
      }
    } else if (pre[v] < pre[u] && v != fa) {
      S.push(e);
      lowu = min(lowu, pre[v]);
    }
  }
  if (fa < 0 && child == 1) iscut[u] = 0;
  return lowu;
}
void find_bcc(int n) {
  memset(pre, 0, sizeof(pre));
  memset(iscut, 0, sizeof(iscut));
  memset(bccno, 0, sizeof(bccno));
  dfs_clock = bcc_cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (!pre[i]) dfs(i, -1);
  }
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int a, b;
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &a, &b);
    G[a].push_back(b);
    G[b].push_back(a);
    if (a > b) swap(a, b);
    E[make_pair(a, b)] = i + 1;
  }
  find_bcc(n);
  sort(SW.begin(), SW.end());
  cout << SW.size() << endl;
  for (int b = 0; b < SW.size(); b++) {
    cout << SW[b] << ' ';
  }
  return 0;
}
