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 N = 1e5 + 100;
vector<int> p[N];
int in[N], lw[N], cut[N];
int nm;
pair<int, int> ed[N];
bool br[N];
void init(int x, int pp = 0) {
  in[x] = lw[x] = ++nm;
  int ch = 0;
  for (int i = 0; i < p[x].size(); i++) {
    int y = ed[p[x][i]].first;
    if (y == x) y = ed[p[x][i]].second;
    if (y == pp) continue;
    if (in[y]) {
      lw[x] = min(lw[x], in[y]);
    } else {
      ch++;
      init(y, x);
      lw[x] = min(lw[x], lw[y]);
      if (lw[y] > in[x]) {
        br[p[x][i]] = 1;
      }
      if (!pp && ch > 1) {
        cut[x]++;
      }
      if (pp && lw[y] >= in[x]) {
        cut[x]++;
      }
    }
  }
}
bool vis[N];
int nEd = 0, nNodes = 0;
set<int> visNodes;
set<int> visEdges;
void dfs(int x, int pp = 0) {
  visNodes.insert(x);
  if (vis[x]) return;
  vis[x] = 1;
  for (int i = 0; i < p[x].size(); i++) {
    int y = ed[p[x][i]].first;
    if (y == x) y = ed[p[x][i]].second;
    visEdges.insert(p[x][i]);
    if (pp == y) continue;
    dfs(y, x);
  }
}
set<int> res;
bool visAdd[N];
void add(int x, int pp = 0) {
  if (visAdd[x]) return;
  visAdd[x] = 1;
  for (int i = 0; i < p[x].size(); i++) {
    int y = ed[p[x][i]].first;
    if (y == x) y = ed[p[x][i]].second;
    if (pp == y) continue;
    res.insert(p[x][i] + 1);
    add(y, x);
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &ed[i].first, &ed[i].second);
    p[ed[i].first].push_back(i);
    p[ed[i].second].push_back(i);
  }
  for (int i = 1; i <= n; i++) {
    if (in[i]) continue;
    init(i);
  }
  for (int i = 1; i <= n; i++) p[i].clear();
  for (int i = 0; i < m; i++) {
    if (br[i]) continue;
    p[ed[i].first].push_back(i);
    p[ed[i].second].push_back(i);
  }
  memset(cut, 0, sizeof cut);
  memset(in, 0, sizeof in);
  memset(lw, 0, sizeof lw);
  nm = 0;
  for (int i = 1; i <= n; i++) {
    if (in[i]) continue;
    init(i);
  }
  for (int i = 1; i <= n; i++) {
    if (vis[i]) continue;
    visEdges.clear();
    visNodes.clear();
    dfs(i);
    int r = 0;
    for (set<int>::iterator it = visNodes.begin(); it != visNodes.end(); it++) {
      r += cut[*it];
    }
    if (visEdges.size() == r + visNodes.size()) add(i);
  }
  cout << res.size() << endl;
  for (set<int>::iterator it = res.begin(); it != res.end(); it++)
    printf("%d ", *it);
  return 0;
}
