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;
int *visited;
int *parent;
int *edgr;
int *pre;
int *post;
list<pair<int, int> > *L;
int k;
list<int> *edges;
int alladin = 0;
void dfs(int z) {
  visited[z] = 1;
  pre[z] = k;
  k++;
  list<pair<int, int> >::iterator itr;
  for (itr = L[z].begin(); itr != L[z].end(); itr++) {
    if (visited[itr->first] == 0) {
      parent[itr->first] = z;
      edgr[itr->first] = itr->second;
      dfs(itr->first);
    }
  }
  post[z] = k;
  k++;
  return;
}
void dfs_dumm(int z) {
  visited[z] = 1;
  list<pair<int, int> >::iterator itr;
  for (itr = L[z].begin(); itr != L[z].end(); itr++) {
    if (visited[itr->first] == 0) {
      dfs_dumm(itr->first);
    } else {
      if (parent[z] != itr->first) {
        if (pre[z] > pre[itr->first] && post[z] < post[itr->first]) {
          int found = 0;
          int prent = z;
          edges[alladin].push_back(itr->second);
          while (prent != itr->first) {
            edges[alladin].push_back(edgr[prent]);
            prent = parent[prent];
          }
          alladin++;
        }
      }
    }
  }
  return;
}
int main(int argc, char const *argv[]) {
  int vert, edges1;
  cin >> vert >> edges1;
  list<pair<int, int> > Ltemp[vert + 1];
  L = Ltemp;
  for (int i = 0; i < edges1; i++) {
    int t1, t2;
    cin >> t1 >> t2;
    L[t1].push_back(make_pair(t2, i + 1));
    L[t2].push_back(make_pair(t1, i + 1));
  }
  list<int> ees[vert + 1];
  edges = ees;
  list<pair<int, int> >::iterator itr;
  list<int>::iterator itm;
  visited = (int *)malloc(sizeof(int) * (vert + 1));
  parent = (int *)malloc(sizeof(int) * (vert + 1));
  pre = (int *)malloc(sizeof(int) * (vert + 1));
  post = (int *)malloc(sizeof(int) * (vert + 1));
  edgr = (int *)malloc(sizeof(int) * (vert + 1));
  for (int i = 0; i < vert + 1; i++) visited[i] = 0, parent[i] = -1;
  k = 0;
  for (int i = 1; i <= vert; i++) {
    if (visited[i] == 0) {
      parent[i] = 0;
      dfs(i);
      for (int j = 0; j < vert + 1; j++) visited[j] = 0;
      dfs_dumm(i);
    }
  }
  set<int, less<int> > arr_;
  int size2 = 0;
  int fuck = 0;
  int coun_ = 1;
  for (int i = 0; i < alladin; i++) {
    for (itm = edges[i].begin(); itm != edges[i].end(); itm++) {
      int size1;
      arr_.insert(*itm);
      size1 = arr_.size();
      if (size1 == size2) {
        cout << "0" << endl;
        return 0;
      } else {
        size2 = size1;
      }
    }
  }
  set<int, less<int> >::iterator uu;
  cout << arr_.size() << endl;
  for (uu = arr_.begin(); uu != arr_.end(); uu++) {
    cout << *uu << " ";
  }
  cout << endl;
  return 0;
}
