#DSU0000010. Bò và đồ ăn nhẹ (Cow and Snacks)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Bò và đồ ăn nhẹ (Cow and Snacks)
Cow and Snacks
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
There are snack flavors, with exactly one snack of each flavor. Each of the guests likes exactly two distinct flavors and eats all remaining snacks of both preferred flavors when served. A guest is unhappy if both preferred flavors are unavailable. You may choose the order in which guests are served. Minimize the number of unhappy guests.
Input
The first line contains two integers . Each of the next lines contains two integers , denoting the two flavors preferred by one guest. Flavors are numbered from to .
Output
Print the minimum possible number of unhappy guests.
Subtasks
- Subtask 1 (20 points): ; ; ; .
- Subtask 2 (30 points): ; ; ; .
- Subtask 3 (50 points): ; ; ; .
Examples
Input
5 4
1 2
4 3
1 4
3 4
Output
1
Explanation
Serve guests in the order . Guest eats flavors and , guest eats flavor , and guest eats flavor . No preferred snack remains for guest , so one guest is unhappy.