690_C2. Brain Network (medium)
Further research on zombie thought processes yielded interesting results. As we know from the previous problem, the nervous system of a zombie consists of n brains and m brain connectors joining some pairs of brains together. It was observed that the intellectual abilities of a zombie depend mainly on the topology of its nervous system. More precisely, we define the distance between two brains u and v (1 ≤ u, v ≤ n) as the minimum number of brain connectors used when transmitting a thought between these two brains. The brain latency of a zombie is defined to be the maximum distance between any two of its brains. Researchers conjecture that the brain latency is the crucial parameter which determines how smart a given zombie is. Help them test this conjecture by writing a program to compute brain latencies of nervous systems.

In this problem you may assume that any nervous system given in the input is valid, i.e., it satisfies conditions (1) and (2) from the easy version.

Input

The first line of the input contains two space-separated integers n and m (1 ≤ n, m ≤ 100000) denoting the number of brains (which are conveniently numbered from 1 to n) and the number of brain connectors in the nervous system, respectively. In the next m lines, descriptions of brain connectors follow. Every connector is given as a pair of brains a b it connects (1 ≤ a, b ≤ n and a ≠ b).

Output

Print one number – the brain latency.

Examples

Input

4 3
1 2
1 3
1 4


Output

2

Input

5 4
1 2
2 3
3 4
3 5


Output

3
```python
import copy
import sys
import threading

threading.stack_size(64 * 1024 * 1024)
sys.setrecursionlimit(10 ** 6)

n, m = map(int, input().split())

ans = 0
sz = [0] * (n + 1)
graph = []

for _ in range(n + 1):
    graph.append([])

for _ in range(m):
    u, v = map(int, input().split())
    graph[u].append(v)
    graph[v].append(u)

def dfs(v, pr):
    global ans
    for to in graph[v]:
        if to != pr:
            dfs(to, v)
    if pr != -1:
        ans = max(ans, sz[pr] + sz[v])
        sz[pr] = max(sz[pr], sz[v] + 1)

def main():
    dfs(1, -1)
    print(ans + 1)
    
th = threading.Thread(target=main)
th.start()
```