#include <bits/stdc++.h>
inline int read() {
  int data = 0, w = 1;
  char ch = getchar();
  while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
  if (ch == '-') w = -1, ch = getchar();
  while (ch >= '0' && ch <= '9') data = data * 10 + (ch ^ 48), ch = getchar();
  return data * w;
}
const int N(1e4 + 10);
struct edge {
  int next, to;
} e[N << 1];
int n, m, head[N], e_num = 1, vis[N], used[N], col[N], s[N], E, cnt;
std::vector<int> ans;
inline void add_edge(int from, int to) {
  e[++e_num] = (edge){head[from], to}, head[from] = e_num;
}
void dfs(int x) {
  vis[x] = 1;
  for (int i = head[x]; i; i = e[i].next) {
    int to = e[i].to;
    if (!vis[to])
      col[to] = col[x] ^ 1, used[i >> 1] = 1, dfs(to);
    else if (!used[i >> 1]) {
      used[i >> 1] = 1;
      if (col[x] == col[to])
        ++cnt, E = i >> 1, ++s[x], --s[to];
      else
        --s[x], ++s[to];
    }
  }
}
void solve(int x) {
  vis[x] = 1;
  for (int i = head[x]; i; i = e[i].next) {
    int to = e[i].to;
    if (vis[to]) continue;
    solve(to), s[x] += s[to];
    if (s[to] == cnt) ans.push_back(i >> 1);
  }
}
int main() {
  n = read(), m = read();
  for (int i = 1, a, b; i <= m; i++)
    a = read(), b = read(), add_edge(a, b), add_edge(b, a);
  for (int i = 1; i <= n; i++)
    if (!vis[i]) dfs(i);
  if (cnt == 0) {
    printf("%d\n", m);
    for (int i = 1; i <= m; i++) printf("%d ", i);
    return 0;
  }
  std::memset(vis + 1, 0, n << 2);
  for (int i = 1; i <= n; i++)
    if (!vis[i]) solve(i);
  if (cnt == 1) ans.push_back(E);
  std::sort(ans.begin(), ans.end()), printf("%lu\n", ans.size());
  for (auto i : ans) printf("%d ", i);
  return 0;
}
