You are given an undirected graph G that contains n nodes and m edges. It is also mentioned that G does not contain any cycles. A sequence of nodes (A1,A2,A3,...Ak) is special if distance d(Ai,Ai+1)=f.i ∀ 1≤i<k, and all Ai are distinct. Determine the size of a maximal special sequence. Hence, the one with maximum k.
Note
Input format
Output format
Print the maximum value of k.
Constraints
1≤f,n<100000,1≤m<n
This graph is not connected. Two separate components are formed denoted as follows:
1−2−34−5
In this case, the maximal beautiful sequence is of length 3.