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 + 2;
set<int> dfsT[N];
vector<int> g[N];
int n, m;
int vis[N];
map<long long, int> edg = {};
void dfs1(int v) {
  vis[v] = 1;
  for (int c : g[v]) {
    if (!vis[c]) {
      dfsT[v].insert(c);
      dfsT[c].insert(v);
      dfs1(c);
    }
  }
}
void fillLca() {
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      dfs1(i);
    }
  }
  memset(vis, 0, sizeof vis);
}
int prep[N];
vector<int> ansl = {};
set<int> merges[N];
map<int, int> ans = {};
set<int> ille = {};
void dfs3(int u, int v) {
  vis[u] = 1;
  for (int x : dfsT[u]) {
    if (x == v) continue;
    dfs3(x, u);
    if (merges[x].size() == 1) ans[edg[u * 1000004ll + x]] = *merges[x].begin();
    if (merges[u].size() < merges[x].size()) {
      swap(merges[u], merges[x]);
    }
    for (int c : merges[x]) {
      if (merges[u].count(c)) {
        merges[u].erase(c);
      } else {
        merges[u].insert(c);
      }
    }
  }
  if (merges[u].size() > 1 || merges[u].count(-1)) {
    for (int k : merges[u]) {
      ille.insert(k);
    }
    merges[u].clear();
    merges[u].insert(-1);
  }
}
void chek() {
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      dfs3(i, i);
    }
  }
}
vector<pair<int, int>> endchk = {};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  int edgs[m][2];
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    edg[a * 1000004ll + b] = i + 1;
    edg[b * 1000004ll + a] = i + 1;
    g[a].push_back(b);
    g[b].push_back(a);
    edgs[i][0] = a;
    edgs[i][1] = b;
  }
  fillLca();
  int c = 1;
  for (int i = 1; i <= n; i++) {
    for (int x : g[i]) {
      if (x > i && !dfsT[i].count(x)) {
        endchk.push_back({edg[i * 1000004ll + x], c});
        if (c == 1018) {
          for (int r : g[i]) {
            cout << r << " ";
          }
          cout << endl;
          for (int r : g[x]) {
            cout << r << " ";
          }
          cout << endl;
        }
        merges[i].insert(c);
        merges[x].insert(c++);
      }
    }
  }
  chek();
  vector<int> arr[m];
  for (auto c : ans) {
    if (!ille.count(c.second)) {
      arr[c.second].push_back(c.first);
    }
  }
  for (int i = 0; i < m; i++) {
    set<int> zz = {};
    for (int x : arr[i]) {
      if (zz.count(edgs[x - 1][0]))
        zz.erase(edgs[x - 1][0]);
      else
        zz.insert(edgs[x - 1][0]);
      if (zz.count(edgs[x - 1][1]))
        zz.erase(edgs[x - 1][1]);
      else
        zz.insert(edgs[x - 1][1]);
    }
    if (zz.size() == 2) {
      long long val = *zz.begin() * 1000004ll + *(++zz.begin());
      if (edg[val] > 0)
        for (int x : arr[i]) ansl.push_back(x);
    }
  }
  for (auto x : endchk) {
    if (!ille.count(x.second)) {
      if (n == 6451) {
        cout << x.first << " " << x.second << endl;
      }
      ansl.push_back(x.first);
    }
  }
  sort(ansl.begin(), ansl.end());
  cout << ansl.size() << endl;
  for (int i : ansl) {
    cout << i << " ";
  }
  cout << endl;
}
