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 MOD = 1000000007;
const int INF = 2e9;
const long long INFLL = 1e18;
const int MAX_N = 200000;
const int MAX_M = 200000;
int N, M;
vector<pair<int, int> > gp[MAX_N + 1];
pair<int, int> p[MAX_N + 1];
int lv[MAX_N + 1], cnt[MAX_N + 1];
bool vst[MAX_N + 1];
vector<pair<int, int> > ans;
vector<int> vt;
pair<int, int> up[MAX_N + 1];
vector<int> group[MAX_M + 1];
int num[MAX_M + 1];
int gnum = 0;
vector<int> v;
void dfs(int x) {
  if (0) cout << x << endl;
  vst[x] = true;
  up[x] = {-1, -1};
  for (int ii = 0; ii < gp[x].size(); ii++) {
    pair<int, int> i = gp[x][ii];
    if (i.first == p[x].first) continue;
    if (!vst[i.first]) {
      p[i.first] = {x, i.second};
      lv[i.first] = lv[x] + 1;
      dfs(i.first);
      if (up[i.first].first == x) continue;
      if (up[x].first == -1) {
        up[x] = up[i.first];
      } else {
        if (up[i.first].first != -1) {
          if (up[i.first].second != -1) {
            while (!group[up[i.first].second].empty())
              group[up[i.first].second].pop_back();
            up[i.first].second = -1;
          }
          if (up[x].second != -1) {
            while (!group[up[x].second].empty()) group[up[x].second].pop_back();
            up[x].second = -1;
          }
          if (lv[up[i.first].first] < lv[up[x].first]) {
            up[x].first = up[i.first].first;
          }
        }
      }
    } else if (lv[i.first] < lv[x]) {
      if (up[x].first != -1) {
        if (up[x].second != -1) {
          while (!group[up[x].second].empty()) group[up[x].second].pop_back();
        }
        up[x].second = -1;
        if (lv[i.first] < lv[up[x].first]) {
          lv[up[x].first] = i.first;
        }
      } else {
        up[x].first = i.first;
        up[x].second = gnum;
        gnum++;
        group[up[x].second].push_back(i.second);
      }
    }
  }
  if (0) cout << x << " " << up[x].first << " " << up[x].second << endl;
  if (up[x].second >= 0) {
    group[up[x].second].push_back(p[x].second);
  }
}
int main() {
  scanf("%d%d", &N, &M);
  for (int i = 1; i <= M; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    gp[a].push_back({b, i});
    gp[b].push_back({a, i});
  }
  for (int i = 1; i <= N; i++) {
    if (!vst[i]) {
      lv[i] = 1;
      dfs(i);
    }
  }
  for (int i = 0; i < gnum; i++) {
    for (int k : group[i]) {
      v.push_back(k);
    }
  }
  sort(v.begin(), v.end());
  printf("%d\n", (int)v.size());
  for (int i = 0; i < v.size(); i++) {
    printf("%d ", v[i]);
  }
  return 0;
}
