#C517. Destroy the Tree by Removing Leaves

    ID: 48789 Type: Default 1000ms 256MiB

Destroy the Tree by Removing Leaves

Destroy the Tree by Removing Leaves

You are given a tree with \(n\) nodes and \(n-1\) edges. The tree is an acyclic connected graph. In one step, you can remove all leaf nodes (nodes with degree 1) simultaneously. The process continues until only one node (or none) remain.

Your task is to determine the total number of steps required to completely reduce the tree by repeatedly removing its leaves.

Note: A leaf is a node with exactly one adjacent node. For a tree with a single node, the number of steps is 0.

inputFormat

The input is read from standard input (stdin) in the following format:

The first line contains an integer \(n\) \( (1 \leq n \leq 10^5)\), the number of nodes in the tree.
The second line contains an integer \(m\) which will be equal to \(n-1\) (or 0 if \(n=1\)).
Each of the next \(m\) lines contains two space-separated integers \(u\) and \(v\) (1-based indexing) representing an edge in the tree.

outputFormat

Output one integer on a single line representing the total number of steps required to destroy the tree by repeatedly removing all its leaves.

Print the result to standard output (stdout).

## sample
5
4
1 2
1 3
3 4
3 5
2