Rivalries
시간 제한1초메모리 제한2048 MB
각 학과가 라이벌로 지목한 학과가 하나씩 주어질 때, 한쪽만 지목해도 쌍이 성립한다고 보고 짝을 짓지 못하는 학과 수의 최솟값을 구한다.
문제
At the prestigious Colorado School of Mines, interdepartmental rivalries are both intense and theatrical. Each department considers exactly one other department as their rival. However, rivalries are not always reciprocated—a department may view another as their rival without that feeling being mutual.
The administration, seeking to foster cooperation despite these rivalries, has decided to form rivalry pairs for an upcoming school-wide fundraising event. Each rivalry pair consists of two departments where either:
- One department considers the other as a rival, or
- They consider each other as rivals.
The administration wants to maximize the number of rivalry pairs to have as many departments as they can at the fundraising event, but due to the asymmetric nature of rivalries, it may not be possible to pair up every department. Some departments will be left without a pair.
Given the rivalry preferences of all departments, and that the administration will maximize the number of departments at the event, determine the minimum number of departments that cannot be paired.
입력
The first line contains a single integer () — the number of departments.
The second line contains space-separated integers (), where represents the department that department considers as its rival. A department may consider itself a rival, i.e., .
출력
Print a single integer---the minimum number of departments that cannot be paired.