n, m = map(int, input().split()) C = [0 for _ in range(n)] for _ in range(m): u, v = map(int, input().split()) u -= 1 v -= 1 C[u] -= 1 C[v] += 1 ans = 0 for i in range(n): ans += max(C[i], 0) print(ans - 1)