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;
class Edge {
 public:
  int to;
  int id;
  Edge(int v, int i) : to(v), id(i) {}
  Edge() {}
};
void get_cutpts_and_bridges();
void tarjan(int u, int f);
void solve();
void dfs(int u, int f, int &cnt);
const int MAX = 1e5 + 5;
vector<Edge> graph[MAX];
set<int> bridges[MAX];
int dfn[MAX], low[MAX], belong[MAX], dfcnt, scc;
int parent[MAX];
bool is_cutpt[MAX], is_bridge[MAX];
int degree[MAX];
bool is_simple[MAX];
int n, m;
set<int> res;
int main() {
  while (scanf("%d %d", &n, &m) != EOF) {
    for (int i = 0; i < MAX; i++) {
      graph[i].clear();
      bridges[i].clear();
    }
    memset(dfn, -1, sizeof(dfn));
    memset(low, -1, sizeof(low));
    memset(belong, -1, sizeof(belong));
    dfcnt = 0;
    memset(parent, -1, sizeof(parent));
    memset(is_cutpt, false, sizeof(is_cutpt));
    memset(is_bridge, false, sizeof(is_bridge));
    res.clear();
    int u, v;
    for (int i = 1; i <= m; i++) {
      scanf("%d %d", &u, &v);
      graph[u].push_back(Edge(v, i));
      graph[v].push_back(Edge(u, i));
    }
    get_cutpts_and_bridges();
    solve();
    printf("%d\n", res.size());
    for (set<int>::iterator it = res.begin(); it != res.end(); it++) {
      if (it != res.begin()) printf(" ");
      printf("%d", *it);
    }
    printf("\n");
  }
  return 0;
}
void get_cutpts_and_bridges() {
  int res = 0;
  tarjan(1, -1);
  int rootson = 0;
  for (int i = 2; i <= n; i++) {
    int v = parent[i];
    if (v == 1) {
      rootson++;
    } else {
      if (low[i] >= dfn[v]) is_cutpt[v] = true;
    }
  }
  if (rootson >= 2) is_cutpt[1] = true;
  for (int i = 1; i <= n; i++) {
    int v = parent[i];
    if (v != -1 && v != 0 && low[i] > dfn[v]) {
      bridges[i].insert(v);
      bridges[v].insert(i);
    }
  }
}
void tarjan(int u, int f) {
  dfn[u] = low[u] = ++dfcnt;
  parent[u] = f;
  for (int i = 0; i < graph[u].size(); i++) {
    Edge &e = graph[u][i];
    int v = e.to;
    if (dfn[v] == -1) {
      tarjan(v, u);
      low[u] = min(low[u], low[v]);
    } else if (parent[u] != v) {
      low[u] = min(low[u], dfn[v]);
    }
  }
}
void solve() {
  memset(belong, -1, sizeof(belong));
  memset(degree, 0, sizeof(degree));
  memset(is_simple, true, sizeof(is_simple));
  for (int u = 1; u <= n; u++)
    for (int i = 0; i < graph[u].size(); i++) {
      Edge &e = graph[u][i];
      int v = e.to;
      if (bridges[u].count(v)) continue;
      degree[u]++;
    }
  int cnt = 0;
  for (int u = 1; u <= n; u++) {
    dfs(u, 0, cnt);
  }
  for (int u = 1; u <= n; u++) {
    if (degree[u] > 2) {
      is_simple[belong[u]] = false;
    }
  }
  for (int u = 1; u <= n; u++)
    for (int i = 0; i < graph[u].size(); i++) {
      Edge &e = graph[u][i];
      int v = e.to;
      if (bridges[u].count(v)) continue;
      if (belong[u] == belong[v] && is_simple[belong[u]]) {
        res.insert(e.id);
      }
    }
}
void dfs(int u, int f, int &cnt) {
  if (belong[u] != -1) return;
  if (f == 0) {
    belong[u] = ++cnt;
  } else {
    belong[u] = belong[f];
  }
  for (int i = 0; i < graph[u].size(); i++) {
    Edge &e = graph[u][i];
    int v = e.to;
    if (bridges[u].count(v)) continue;
    dfs(v, u, cnt);
  }
}
