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 double eps = 1e-9;
const int MAXE = 1.1e5;
const int MAXN = MAXE;
int ed[MAXE][4];
vector<int> adj[MAXN];
int N, M, D;
int dfsnr[MAXN];
int revnr[MAXN];
int mark[MAXN];
int comp[MAXN], C;
void dfs(int n, int p = -1) {
  if (dfsnr[n] != -1) return;
  revnr[n] = dfsnr[n] = D++;
  for (auto it : adj[n]) {
    int to = ed[it][2] ^ n;
    if (to == p) continue;
    if (dfsnr[to] == -1) {
      comp[C++] = it;
      dfs(to, n);
      revnr[n] = min(revnr[n], revnr[to]);
      if (revnr[to] >= dfsnr[n]) {
        unordered_set<int> cur;
        while (comp[--C] != it) cur.insert(comp[C]);
        cur.insert(it);
        unordered_map<int, int> cnt;
        for (auto it2 : cur)
          for (int i = (0); i < (2); i++) cnt[ed[it2][i]] += 1;
        bool ok = true;
        for (auto it2 : cnt)
          if (it2.second != 2) ok = false;
        if (!ok)
          for (auto it2 : cur) ed[it2][3] = 1;
      }
    } else {
      if (dfsnr[to] < dfsnr[n]) comp[C++] = it;
      revnr[n] = min(revnr[n], dfsnr[to]);
    }
  }
}
int main() {
  if (0 == scanf("%d%d", &N, &M)) {
    fprintf(stderr, "Could not parse arguments\n");
  };
  for (int i = (0); i < (M); i++)
    if (0 == scanf("%d%d", &(ed[i][0]), &(ed[i][1]))) {
      fprintf(stderr, "Could not parse arguments\n");
    };
  for (int i = (0); i < (M); i++) ed[i][2] = ed[i][0] ^ ed[i][1];
  for (int i = (0); i < (M); i++) ed[i][3] = 0;
  for (int i = (0); i < (N + 1); i++) adj[i].clear();
  for (int i = (0); i < (M); i++)
    for (int j = (0); j < (2); j++) adj[ed[i][j]].push_back(i);
  for (int i = (0); i < (N + 1); i++) dfsnr[i] = -1;
  D = 0;
  for (int i = (0); i < (N + 1); i++) {
    C = 0;
    dfs(i);
  }
  int K = 0;
  for (int i = (0); i < (M); i++)
    if (ed[i][3] == 0) ++K;
  printf("%d\n", K);
  bool first = true;
  for (int i = (0); i < (M); i++)
    if (ed[i][3] == 0) {
      if (first)
        first = false;
      else
        printf(" ");
      printf("%d", i + 1);
    }
  printf("\n");
  return 0;
}
