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 n, m, cnt, slt;
int name[100001] = {0};
std::pair<int, int> liste[100001];
std::vector<int> e[100001];
std::vector<int>::iterator it;
bool specialVertice[100001] = {false};
int num[100001], low[100001], child[100001] = {0};
std::stack<int> s;
void tajan(int first, int curu) {
  ++cnt;
  num[first] = cnt;
  low[first] = cnt;
  child[first] = 1;
  s.push(first);
  for (int i = 0; i < e[first].size(); ++i) {
    int second = e[first][i];
    if (second == curu) continue;
    if (num[second] != 0)
      low[first] = std::min(low[first], num[second]);
    else {
      ++child[first];
      tajan(second, first);
      specialVertice[first] =
          specialVertice[first] & (low[second] >= num[first]);
      low[first] = std::min(low[first], low[second]);
    }
  }
  if (num[first] == low[first]) {
    ++slt;
    int second;
    do {
      second = s.top();
      name[second] = slt;
      s.pop();
    } while (second != first);
  }
}
void tjalg() {
  for (int i = 1; i < n + 1; ++i) {
    num[i] = 0;
    name[i] = 0;
  }
  cnt = 0;
  slt = 0;
  for (int i = 1; i < n + 1; ++i)
    if (!num[i]) {
      tajan(i, i);
      specialVertice[i] = specialVertice[i] & (child[i] > 1);
    }
}
void enter() {
  std::cin >> n >> m;
  for (int i = 1; i < m + 1; ++i) {
    std::cin >> liste[i].first >> liste[i].second;
    e[liste[i].first].push_back(liste[i].second);
    e[liste[i].second].push_back(liste[i].first);
  }
}
int ce[100001] = {0};
void built() {
  for (int i = 1; i < m + 1; ++i) {
    int nu = name[liste[i].first];
    int nv = name[liste[i].second];
    if (nu == nv) {
      ++ce[liste[i].first];
      ++ce[liste[i].second];
    }
  }
}
void quest() {
  int ans = 0;
  for (int i = 1; i < m + 1; ++i) {
    int nu = name[liste[i].first];
    int nv = name[liste[i].second];
    if (nu == nv) {
      bool cu = (ce[liste[i].first] == 2) | specialVertice[liste[i].first];
      bool cv = (ce[liste[i].second] == 2) | specialVertice[liste[i].second];
      if (cu & cv) ++ans;
    }
  }
  std::cout << ans << '\n';
  for (int i = 1; i < m + 1; ++i) {
    int nu = name[liste[i].first];
    int nv = name[liste[i].second];
    if (nu == nv) {
      bool cu = (ce[liste[i].first] == 2) | specialVertice[liste[i].first];
      bool cv = (ce[liste[i].second] == 2) | specialVertice[liste[i].second];
      if (cu & cv) std::cout << i << ' ';
    }
  }
}
int main() {
  enter();
  tjalg();
  built();
  quest();
  return 0;
}
