
n, m = input().split(" ")
n, m = int(n), int(m)
neighbours = []
pipes = []
removed = 0

for i in range(n):
    neighbours.append([0, 0])

for i in range(m):
    x, y = input().split(" ")
    x, y = int(x)  - 1, int(y) - 1
    neighbours[x][0] += 1
    neighbours[y][1] += 1
    pipes.append((x, y))

for p in pipes:
    if neighbours[p[0]][0] > 1 and neighbours[p[1]][1] > 1:
        removed += 1
        neighbours[p[0]][0] -= 1
        neighbours[p[1]][1] -= 1

    
print(removed)
