Oola and the Rabbits


Submit solution

Points: 25
Time limit: 1.0s
Memory limit: 256M

Author:
Problem type

Oola the scientist is conducting social experiments on rabbits (because she does not like cats). Recently, she taught her rabbits the power of friendship, because she thinks that's important. Her rabbits talk between each other only if they are friends.

Today, she want to know how fast rumours are spread in her rabbit community. More specifically, if rabbit \(R\) starts a rumour, how much time will it take for it to reach everyone? When rabbit \(R\) starts a rumour, it will send it to all its friends, then likewise, the ones who received the rumour will spread it to their friends until everyone know about it.

If it takes 1 unit of time for a rabbit to send a message to its friends, Oola wonders how much time will it take, in the worst case, for a rumour to spread. She is very busy now, because she traveling to London, so she entrusts you dear reader to solve it for her.

Input Specification

Input starts with two numbers \(N\), and \(M\) denoting the number of rabbits, and the number of friendships respectively \(1 \le N \le 50\) and \(N - 1 \le M \le 2500\). Then \(M\) lines follow, each containing two numbers \(a\), and \(b\) meaning that \(rabbit_a\) and \(rabbit_b\) are friends. Rabbit ids are between 0 and \(N - 1\).

Output Specification

For each test case output the worst case a rumour can be spread.

Sample Input

2 1
1 0

Sample Output

1

Sample Input

3 2
0 1
1 2

Sample Output

2

Notes

In the first test case, two rabbits that are friends, it will take one unit of time for them to talk.

In the second test case, rabbit 0 is friend with rabbit 1, and rabbit 1 is friend with rabbit 2. If rumour starts from rabbit 2, then it will take two units of time to reach the first rabbit.

Note that rabbit friendship is mutual and that the rabbit community is always connected.


Comments


  • 0
    Mouad_Ouj  commented on July 30, 2021, 11:33 p.m.

    I don't know where is the problem in my code