By Microsoft Serbia
You are in charge of the BubbleReactor. It consists of N BubbleCores connected with N lines of electrical wiring. Each electrical wiring connects two distinct BubbleCores. There are no BubbleCores connected with more than one line of electrical wiring.
Your task is to start the BubbleReactor by starting each BubbleCore. In order for a BubbleCore to be started it needs to be receiving power from a directly connected BubbleCore which is already started. However, you can kick-start one BubbleCore manually without needing power. It is guaranteed that all BubbleCores can be started.
Before the BubbleCore boot up procedure its potential is calculated as the number of BubbleCores it can power on (the number of inactive BubbleCores which are connected to it directly or with any number of inactive BubbleCores in between, itself included)
Start the BubbleReactor so that the sum of all BubbleCores’ potentials is maximum.
First line contains one integer N (3 ≤ N ≤ 15.000), the number of BubbleCores.
The following N lines contain two integers U, V (0 ≤ U \(\neq\) V < N ) denoting that there exists electrical wiring between BubbleCores U and V.
Single integer, the maximum sum of all BubbleCores’ potentials.
|Input Sample||Output Sample|