eolymp
bolt
Try our new interface for solving problems
Problems

Even Tree

Even Tree

You are given a tree (a simple connected graph without cycles). Find the maximum number of edges you can remove from the tree to get a forest such that each connected component of the forest contains an even number of nodes. As an example, the following tree with $4$ nodes can be cut at most $1$ time to create an even forest. \includegraphics{https://static.eolymp.com/content/a8/a89012becfc305c8093cfa63e76ac4d99df61b01.gif} \InputFile The first line contains two integers $n~(2 \le n \le 100, n$ is even) and $m$ --- the number of nodes and edges. The next $m$ lines contain two integers which specify the nodes connected by an edge of the tree. The root of the tree is node $1$. \OutputFile Print the maximum number of removed edges. \includegraphics{https://static.eolymp.com/content/9b/9b04cb27d172cca99402a7db2625764b564cb1a7.gif}
Time limit 1 second
Memory limit 128 MiB
Input example #1
10 9
2 1
3 1
4 3
5 2
6 1
7 2
8 6
9 8
10 8
Output example #1
2