N, K = map(int, input().split()) g0 = [0]*(N+1) g1 = [0]*(N+1) for _ in range(K): a, b = map(int, input().split()) g0[a] += 1 g1[b] += 1 ans = max(sum(abs(a-b) for a, b in zip(g0, g1))//2-1, 0) print(ans)