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 

from sys import stdin, stdout
from itertools import repeat
def main():
    n, m = map(int, stdin.readline().split())
    dat = map(int, stdin.read().split(), repeat(10, 2 * m))
    la = [None] * (n + 1)
    xt = [None] * (2 * m)
    j = 0
    for i in xrange(m):
        x, y = dat[j:j+2]
        xt[j] = la[y]
        la[y] = j
        j += 1
        xt[j] = la[x]
        la[x] = j
        j += 1
    st = []
    pu = st.append
    po = st.pop
    est = []
    epu = est.append
    epo = est.pop
    low = [0] * (n + 1)
    f = [0] * (n + 1)
    depth = [0] * (n + 1)
    d = [None] * (n + 1)
    par = [None] * (n + 1)
    c = 1
    ans = [0] * m
    for i in xrange(1, n + 1):
        if d[i] is None:
            pu((i, la[i]))
            while st:
                x, y = po()
                if d[x] == 1:
                    if low[dat[y]] >= depth[x]:
                        ee = []
                        while 1:
                            ex, ey, z = epo()
                            ee.append((ex, ey, z))
                            if ee[-1] == (x, dat[y], y):
                                break
                        cnt = 0
                        for ex, ey, z in ee:
                            if not f[ex]:
                                f[ex] = 1
                                cnt += 1
                            if not f[ey]:
                                f[ey] = 1
                                cnt += 1
                        if cnt == len(ee) > 2:
                            for ex, ey, z in ee:
                                ans[z/2] = 1
                        for ex, ey, z in ee:
                            f[ex] = f[ey] = 0
                    if low[x] > low[dat[y]]:
                        low[x] = low[dat[y]]
                    y = xt[y]
                if d[x] is None:
                    d[x] = 1
                    c += 1
                    low[x] = depth[x] = c
                while y is not None:
                    to = dat[y]
                    if d[to] is None:
                        epu((x, to, y))
                        par[to] = x
                        pu((x, y))
                        pu((to, la[to]))
                        break
                    elif to != par[x] and low[x] >= depth[to]:
                        epu((x, to, y))
                        low[x] = depth[to]
                    y = xt[y]
                if y is None:
                    d[x] = 2
    ans = [i + 1 for i, x in enumerate(ans) if x]
    ans.sort()
    stdout.write(str(len(ans)))
    stdout.write('\n')
    stdout.write(' '.join(map(str, ans)))
    stdout.write('\n')
main()
