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 Scanner {
 private:
  static const int BUFFER_SIZE = 10000;
  char buff[BUFFER_SIZE];
  int buffPos, buffLim;

 public:
  Scanner() {
    buffLim = fread(buff, 1, BUFFER_SIZE, stdin);
    buffPos = 0;
  }

 private:
  inline void flushBuff() {
    buffLim = fread(buff, 1, BUFFER_SIZE, stdin);
    if (buffLim == 0) {
      buff[buffLim++] = '\n';
    }
    buffPos = 0;
  }
  inline bool isWS(char t) { return t == ' ' || t == '\n'; }
  inline bool isDig(char t) { return t >= '0' && t <= '9'; }
  void nextPos() {
    buffPos++;
    if (buffPos == buffLim) {
      flushBuff();
    }
  }

 public:
  inline char getchar() {
    char ch = buff[buffPos];
    nextPos();
    return ch;
  }
  inline void next(char* s) {
    while (isWS(buff[buffPos])) {
      nextPos();
    }
    while (!isWS(buff[buffPos])) {
      *s = buff[buffPos];
      s++;
      nextPos();
    }
    *s = '\0';
  }
  inline void nextLine(char* s) {
    while (buff[buffPos] != '\n') {
      nextPos();
    }
    if (buff[buffPos] == '\n') {
      nextPos();
    }
    while (buff[buffPos] != '\n') {
      *s = buff[buffPos];
      s++;
      buffPos++;
    }
    *s = '\0';
  }
  inline int nextInt() {
    while (!isDig(buff[buffPos]) && buff[buffPos] != '-') {
      nextPos();
    }
    int sign = (buff[buffPos] == '-') ? nextPos(), -1 : 1;
    int res = 0;
    while (isDig(buff[buffPos])) {
      res = res * 10 + buff[buffPos] - '0';
      nextPos();
    }
    return res * sign;
  }
  inline double nextDouble() {
    while (isWS(buff[buffPos])) {
      nextPos();
    }
    int sign = (buff[buffPos] == '-') ? nextPos(), -1 : 1;
    double res = 0;
    while (isDig(buff[buffPos])) {
      res = res * 10 + buff[buffPos] - '0';
      nextPos();
    }
    if (buff[buffPos] == '.') {
      nextPos();
      double ep = 1;
      while (isDig(buff[buffPos])) {
        ep *= 0.1;
        res += ep * (buff[buffPos] - '0');
        nextPos();
      }
    }
    return sign * res;
  }
  inline char nextChar() {
    while (isWS(buff[buffPos])) nextPos();
    char res = buff[buffPos];
    nextPos();
    return res;
  }
};
Scanner sc;
template <class T>
inline bool checkMin(T& a, T b) {
  return (a > b ? a = b, 1 : 0);
}
template <class T>
inline bool checkMax(T& a, T b) {
  return (a < b ? a = b, 1 : 0);
}
void ALERT(bool judgememt, const char* phrase) {
  if (judgememt) {
    puts(phrase);
    throw "ALERT";
  }
}
bool alert(bool judgememt, const char* phrase) {
  if (judgememt) puts(phrase);
  return judgememt;
}
void preInit();
void init();
void solve();
int32_t main() {
  preInit();
  init();
  solve();
  return 0;
}
const int N = 100005;
struct Tree {
  int ef[N], en[N * 2], ev[N * 2], ei[N * 2], ec;
  Tree() {
    ec = 0;
    memset(ef, -1, sizeof(ef));
    memset(en, -1, sizeof(en));
  }
  void addEdge(int u, int v, int id) {
    ;
    en[ec] = ef[u];
    ef[u] = ec;
    ev[ec] = v;
    ei[ec] = id;
    ec++;
    en[ec] = ef[v];
    ef[v] = ec;
    ev[ec] = u;
    ei[ec] = id;
    ec++;
  }
};
int n, m;
struct Tree2 : public Tree {
  int low[N], dfn[N], dfnCnt;
  stack<int> st;
  vector<vector<int>> bar;
  void dfs(int u, int f) {
    ;
    dfn[u] = low[u] = ++dfnCnt;
    for (int e = ef[u]; e != -1; e = en[e])
      if (ev[e] != f) {
        int v = ev[e];
        ;
        if (!dfn[v]) {
          st.push(ei[e]);
          dfs(v, u);
          checkMin(low[u], low[v]);
          if (low[v] >= dfn[u]) {
            vector<int> eids;
            while (st.top() != ei[e]) {
              eids.push_back(st.top());
              st.pop();
            }
            eids.push_back(ei[e]);
            st.pop();
            bar.push_back(eids);
          }
        } else if (dfn[v] < dfn[u]) {
          checkMin(low[u], dfn[v]);
          st.push(ei[e]);
        }
      }
  }
  void solve() {
    for (int i = 1; i <= n; i++) {
      if (!dfn[i]) {
        dfs(i, i);
      }
    }
  }
} T;
int u[N], v[N];
void preInit() {}
void init() {
  n = sc.nextInt();
  m = sc.nextInt();
  for (int i = 0; i < m; i++) {
    u[i] = sc.nextInt(), v[i] = sc.nextInt();
    T.addEdge(u[i], v[i], i);
  }
}
size_t count(vector<int>& uu) {
  set<int> st;
  for (int i : uu) {
    st.insert(u[i]);
    st.insert(v[i]);
  }
  return st.size();
}
void solve() {
  T.solve();
  vector<int> ans;
  for (auto& u : T.bar) {
    if (u.size() == count(u)) {
      for (int i : u) {
        ans.push_back(i);
      }
    }
  }
  sort(ans.begin(), ans.end());
  printf("%d\n", static_cast<int>(ans.size()));
  for (int u : ans) {
    printf("%d ", u + 1);
  }
  puts("");
}
