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>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/priority_queue.hpp>
//#pragma GCC optimize("O3")
//#pragma GCC target("sse4")
//#pragma GCC target("avx2")

#define deb(x) cout << #x << " = " << x << "\n"
#define all(x) (x).begin(), (x).end()
#define len(x) (int) x.size()
#define lsb(x) (x) & -(x)
#define l(x) (x << 1) + 1
#define r(x) (x << 1) + 2

#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ld, ld> pld;
typedef pair <ll, ll> pll;

template <class T1, class T2 = less <T1>> using pb_heap = __gnu_pbds::priority_queue <T1, T2, binary_heap_tag>;
template <class T1, class T2 = null_type, class T3 = less <T1>> using pb_map = tree <T1, T2, T3, rb_tree_tag, tree_order_statistics_node_update>;
template <class T1, class T2 = null_type, class T3 = hash <T1>> using pb_umap = gp_hash_table <T1, T2, T3>;
template <class T1, class T2, class T3 = hash <T1>> using umap = unordered_map <T1, T2, T3>;
template <class T> using uset = unordered_set <T>;
template <class T> using vec = vector <T>;

const ll infll = numeric_limits <ll>::max() >> 1;
const int inf = numeric_limits <int>::max() >> 1;
const int N = 1e5 + 1;
int n, m;

vec <int> ans;
stack <int> st;
pb_umap <int> con[N];

int ind[N];
int cnt[N];
int cur;

pii edge[N];

struct Graph {
    int cnt[N];
    int par[N];
    int num[N];
    int low[N];
    bool vis[N];
    vec <pii> adj[N];
} graph;

void input() {
    cin >> n >> m;
    for(int i = 1; i <= m; ++i) {
        int u; cin >> u;
        int v; cin >> v;
        graph.adj[u].pb({v, i});
        graph.adj[v].pb({u, i});
        edge[i] = {u, v};
    }
}

void dfs_count(int u) {
    graph.vis[u] = 1;
    for(pii p: graph.adj[u]) {
        int v = p.xx;
        if(!graph.vis[v]) {
            graph.cnt[u]++;
            dfs_count(v);
        }
    }
}

int dfs(int u) {
    static int t = 0;
    graph.vis[u] = 1;
    graph.low[u] =
    graph.num[u] = ++t;
    for(pii p: graph.adj[u]) {
        int v = p.xx;
        int i = p.yy;
        if(!graph.vis[v]) {
            st.push(i);
            graph.par[v] = u;
            graph.low[u] = min(graph.low[u], dfs(v));
            if(u == 1 && graph.cnt[u] > 1 || u != 1 && graph.low[v] >= graph.num[u]) {
                while(st.top() != i) {
                    ind[st.top()] = cur;
                    con[cur].insert(edge[st.top()].xx);
                    con[cur].insert(edge[st.top()].yy);
                    cnt[cur]++;
                    st.pop();
                }
                ind[st.top()] = cur;
                con[cur].insert(edge[i].xx);
                con[cur].insert(edge[i].yy);
                cnt[cur++]++;
                st.pop();
            }
        }
        else if(graph.par[u] != v) {
            graph.low[u] = min(graph.low[u], graph.num[v]);
            if(graph.num[u] > graph.num[v]) {
                st.push(i);
            }
        }
    }
    return graph.low[u];
}

void biconnected_comp() {
    dfs_count(1);
    fill(graph.vis, graph.vis + N, 0);
    dfs(1);
    while(!st.empty()) {
        ind[st.top()] = cur;
        con[cur].insert(edge[st.top()].xx);
        con[cur].insert(edge[st.top()].yy);
        cnt[cur]++;
        st.pop();
    }
}

void solve() {
    biconnected_comp();
    for(int i = 1; i <= m; ++i) {
        if(cnt[ind[i]] == len(con[ind[i]])) {
            ans.pb(i);
        }
    }
    cout << len(ans) << "\n";
    for(int e: ans) {
        cout << e << " ";
    }
    cout << "\n";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    input();
    solve();
}
