#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int n, m, dep[N], c[N], f[N], tot = 0;
int cnt = 0, hed[N], to[N + N], nxt[N + N];
bool vis[N];
inline void add(int x, int y) {
  to[++cnt] = y, nxt[cnt] = hed[x], hed[x] = cnt;
}
void dfs(int u, int ff) {
  vis[u] = 1, dep[u] = dep[ff] + 1;
  for (int i = hed[u]; i; i = nxt[i]) {
    if (to[i] == ff || dep[to[i]] > dep[u]) continue;
    if (!vis[to[i]])
      dfs(to[i], u), c[u] += c[to[i]], f[i] = c[to[i]];
    else if ((dep[u] ^ dep[to[i]]) & 1)
      --c[u], ++c[to[i]];
    else
      ++c[u], --c[to[i]], f[i] = 1, ++tot;
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1, x, y; i <= m; i++)
    scanf("%d%d", &x, &y), add(x, y), add(y, x);
  for (int i = 1; i <= n; i++)
    if (!vis[i]) dfs(i, 0);
  if (!tot) {
    printf("%d\n", m);
    for (int i = 1; i <= m; i++) printf("%d ", i);
    puts("");
    return 0;
  }
  cnt = 0;
  for (int i = 1; i <= m + m; i++)
    if (f[i] == tot) f[++cnt] = (i + 1) / 2;
  printf("%d\n", cnt);
  for (int i = 1; i <= cnt; i++) printf("%d ", f[i]);
  return 0;
}
