def main(): import sys input = sys.stdin.read().split() ptr = 0 N = int(input[ptr]) ptr += 1 # Read red edges, but ignore them for _ in range(N-1): ptr += 2 # Read black edges degrees = [0] * (N + 1) for _ in range(N-1): a = int(input[ptr]) b = int(input[ptr+1]) ptr += 2 degrees[a] += 1 degrees[b] += 1 # Count the number of leaves in the black tree L = sum(1 for i in range(1, N+1) if degrees[i] == 1) # Compute the result result = (N - 1) + (L - 2) print(result) if __name__ == "__main__": main()