#include <bits/stdc++.h>
using namespace std;
const int N = 1000 * 1000 + 20;
int a[N], visited[N], num_cycle_f, num_cycle_z, cycle_f[N], cycle_z[N], ed_f[N],
    ed_z[N], h[N], cycle_fard, n, m, t, t_main = 0;
vector<int> dfs_edje, ans;
vector<pair<int, int> > e[N];
void dfs(int v, int par, int dady_edje) {
  visited[v] = 1;
  for (int i = 0; i < e[v].size(); i++) {
    int u = e[v][i].first;
    if (visited[u] == 0) {
      dfs_edje.push_back(e[v][i].second);
      h[u] = h[v] + 1;
      dfs(u, v, e[v][i].second);
    } else if (u != par and h[v] > h[u]) {
      if ((h[v] - h[u]) % 2 == 0) {
        cycle_f[u]++;
        cycle_fard = e[v][i].second;
        ed_f[dady_edje]++;
        t++;
        num_cycle_f++;
      } else {
        cycle_z[u]++;
        num_cycle_z++;
        ed_z[dady_edje]++;
      }
    }
  }
}
void dfs_main(int v, int dady_edje) {
  visited[v] = 1;
  for (int i = 0; i < e[v].size(); i++) {
    int u = e[v][i].first;
    if (visited[u] == 0) {
      dfs_main(u, e[v][i].second);
      ed_f[dady_edje] += ed_f[e[v][i].second];
      ed_z[dady_edje] += ed_z[e[v][i].second];
    }
  }
  ed_f[dady_edje] -= cycle_f[v];
  ed_z[dady_edje] -= cycle_z[v];
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    e[y].push_back(make_pair(x, i + 1));
    e[x].push_back(make_pair(y, i + 1));
  }
  for (int i = 1; i <= n; i++) {
    if (visited[i] == 0) {
      dfs(i, -1, 0);
    }
  }
  fill(visited, visited + n + 1, 0);
  for (int i = 1; i <= n; i++) {
    if (visited[i] == 0) {
      t = 0;
      dfs_main(i, 0);
      if (t > 0) {
        t_main++;
      }
    }
  }
  if (t_main > 1) {
    cout << 0;
    return 0;
  }
  if (num_cycle_f == 0) {
    cout << m << "\n";
    for (int i = 1; i <= m; i++) {
      cout << i << ' ';
    }
  } else {
    for (int i = 0; i < dfs_edje.size(); i++) {
      int u = dfs_edje[i];
      if (ed_f[u] == num_cycle_f and ed_z[u] == 0) {
        ans.push_back(u);
      }
    }
    if (num_cycle_f == 1) {
      ans.push_back(cycle_fard);
    }
    sort(ans.begin(), ans.end());
    cout << ans.size() << "\n";
    for (int i = 0; i < ans.size(); i++) {
      cout << ans[i] << " ";
    }
  }
}
