AlgoUniversity
  • Go Back
Discussion
Mail Rooms For Office Buildings :

Author

Ganesh Aggarwal

Difficulty Level : Medium

Submissions : 571

Asked In : Cisco

Marks :10

: 11 | : 0

Company ABC has corporate campus with multiple buildings. These buildings may or may not be connected to one another. Those buildings which are connected form a tree-structure.

Mail rooms are to be setup in some buildings so that all the buildings are served with the following conditions:

  1. Every building can have atmost 1 mail room.
  2. A building having a mail room will serve itself and also service buildings directly connected to it. Hence those directly connected buildings may not host a mail room unless required otherwise.
  3. In case a building is not connected to any other building, then it will need its own mail room.

Please help Alisa determine the least number of mail rooms to be setup so that all buildings are serviced.

Input

The first line contains an integer $$$n$$$ (1 $$$\le$$$ $$$n$$$ $$$\le$$$ $$$10^{5}$$$), the number of buildings.

The second line contains an integer $$$m$$$ (0 $$$\le$$$ $$$m$$$ $$$\le$$$ $$$n-1$$$), the number of connections.

Each of the next $$$m$$$ lines contain two integer $$$u$$$ and $$$v$$$ (1 $$$\le$$$ $$$u$$$,$$$v$$$ $$$\le$$$ $$$n$$$, $$$u$$$ $$$\ne$$$ $$$v$$$), denoting that building $$$u$$$ is directly connected to building $$$v$$$.

Output

A single integer indicating the minimum number of mail rooms needed.

Examples

Input
6
0
Output
6
Input
6
3
2 1
6 1
5 1
Output
3
Input
6
5
1 2
2 3
2 5
5 4
5 6
Output
2

You need to login to view your submissions.

You need to login to view all submissions.

Loading...

Result : Executed

Loading...

Feel something is wrong with the test cases?

Result : Accepted

Test Cases :

You need to Log In
We're glad that you want to attempt this problem!

But to Run or Submit the Problem, you need to Log In.

Continue to Log In
Challenge Submitted!

Your challenge has been submitted successfully.

You will get a response soon via WhatsApp or Email.

Challenge
Facing issue while trying to solve the problem! Don't worry, we got you covered!

Do let us know your issue.

Looks good!
Please enter your issue / feedback.

How do we get in touch with you?
Looks good!
Please enter your phone no.
Looks good!
Please enter your email address.