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 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;
}
