There is a tree with N vertices, numbered 1 through N.

The i-th of the N-1 edges connects the vertices p_i and q_i.

Among the sequences of distinct vertices v_1, v_2, ..., v_M that satisfy the following condition, find the maximum value of M.

* For every 1 \leq i < M, the path connecting the vertices v_i and v_{i+1} do not contain any vertex in v, except for v_i and v_{i+1}.

Constraints

* 2 \leq N \leq 10^5
* 1 \leq p_i, q_i \leq N
* The given graph is a tree.

Input

The input is given from Standard Input in the following format:


N
p_1 q_1
p_2 q_2
:
p_{N-1} q_{N-1}


Output

Print the maximum value of M, the number of elements, among the sequences of vertices that satisfy the condition.

Examples

Input

4
1 2
2 3
2 4


Output

3


Input

10
7 9
1 2
6 4
8 1
3 7
6 5
2 10
9 6
2 6


Output

8
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int n, r, l;
vector<int> g[100010];
int lc[100010];
int d[100010];
void dfs(int x, int p){
	if(g[x].size()==1) lc[x]=1;
	d[x]=1;
	for(auto y:g[x]){
		if(y==p) continue;
		dfs(y, x);
		lc[x]+=lc[y];
	}
	for(auto y:g[x]){
		if(y==p) continue;
		d[x]=max(d[x], max(1, lc[x]-lc[y])+d[y]);
	}
}
int ans;
void dfs2(int x, int p){
	vector<int> v;
	for(auto y:g[x]){
		if(y==p) continue;
		v.push_back(d[y]-lc[y]);
	}
	sort(v.begin(), v.end(), greater<int>());
	if(v.size()>=2) ans=max(ans, v[0]+v[1]+l);
	for(auto y:g[x]){
		if(y==p) continue;
		dfs2(y, x);
	}
}
int main()
{
	cin>>n;
	for(int i=0; i<n-1; i++){
		int a, b;
		cin>>a>>b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	if(n==2){
		cout<<2<<endl;
		return 0;
	}
	r=-1;
	for(int i=0; i<n; i++){
		if(g[i].size()==1) l++;
		else if(g[i].size()>2) r=i;
	}
	if(r==-1){
		cout<<n<<endl;
		return 0;
	}
	dfs(r, -1);
	dfs2(r, -1);
	cout<<ans<<endl;
	return 0;
}