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>
int elist[200000];
bool vis[100000];
bool evis[100000];
int pre[100000];
int pre_max = 0;
int low[100000];
std::vector<int> adj[100000];
std::vector<int> treee[100000];
std::vector<int> backe[100000];
int bcc[100000];
int nbccs = 0;
int extra[100000];
void dfs0(int node) {
  if (vis[node]) return;
  vis[node] = true;
  low[node] = pre[node] = pre_max++;
  for (int e : adj[node]) {
    if (evis[e >> 1]) continue;
    evis[e >> 1] = true;
    if (vis[elist[e ^ 1]]) {
      backe[node].push_back(e);
    } else {
      treee[node].push_back(e);
      dfs0(elist[e ^ 1]);
    }
  }
  for (int e : treee[node]) {
    low[node] = std::min(low[node], low[elist[e ^ 1]]);
  }
  for (int e : backe[node]) {
    low[node] = std::min(low[node], pre[elist[e ^ 1]]);
  }
}
std::vector<int> stk;
void dfs1(int node) {
  for (int e : treee[node]) {
    if (low[elist[e ^ 1]] >= pre[node]) {
      stk.push_back(nbccs++);
    }
    bcc[e >> 1] = stk.back();
    dfs1(elist[e ^ 1]);
    if (low[elist[e ^ 1]] >= pre[node]) {
      stk.pop_back();
    }
  }
  for (int e : backe[node]) {
    bcc[e >> 1] = stk.back();
    extra[stk.back()]++;
  }
}
int main() {
  int N, M;
  scanf("%d %d", &N, &M);
  for (int i = 0; i < M; i++) {
    int U, V;
    scanf("%d %d", &U, &V);
    U--, V--;
    elist[i * 2] = U;
    elist[i * 2 + 1] = V;
    adj[U].push_back(i * 2);
    adj[V].push_back(i * 2 + 1);
  }
  for (int i = 0; i < N; i++) {
    if (!vis[i]) {
      dfs0(i);
      dfs1(i);
    }
  }
  std::vector<int> vs;
  for (int i = 0; i < M; i++) {
    if (extra[bcc[i]] == 1) {
      vs.push_back(i);
    }
  }
  printf("%d\n", (int)vs.size());
  for (int i = 0; i < vs.size(); i++) {
    if (i) printf(" ");
    printf("%d", vs[i] + 1);
  }
  printf("\n");
  return 0;
}
