#include <bits/stdc++.h>

using namespace std;

const int nmax = 20010;

int n, m;
vector < pair <int, int> > g[nmax];
bool used[nmax];
int tin[nmax], up[nmax], timer = 0;
map < pair<int,int>, vector<int> > ans;

void dfs(int v, int p = -1)
{
    used[v] = 1;
    tin[v] = up[v] = ++timer;
    for (int i = 0; i < (int)g[v].size(); ++i)
    {
        int to = g[v][i].first, id = g[v][i].second;
        if (to == p)
            continue;
        if (used[to])
            up[v] = min(up[v], tin[to]);
        else
        {
            dfs(to, v);
            up[v] = min(up[v], up[to]);
            if (up[to] > tin[v])
            {
                bool ch = 0;
                if (v > to)
                    swap(v, to), ch = 1;
                ans[make_pair(v, to)].push_back(id);
                if (ch)
                    swap(v, to);
            }
        }
    }
}

int main()
{
    cin >> n >> m;
    for (int i = 0; i < m; ++i)
    {
        int v, u;
        cin >> v >> u;
        g[v].push_back(make_pair(u, i));
        g[u].push_back(make_pair(v, i));
    }
    for (int i = 1; i <= n; ++i)
        if (!used[i])
            dfs(i);
    set<int> br;
    for (auto i : ans)
        if (i.second.size() == 1)
            br.insert(*i.second.begin() + 1);
    cout << (int)br.size() << "\n";
    for (auto i : br)
        cout << i << "\n";

    return 0;
}