#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
struct tree
{
int fa;
int l;
int r;
int ceng;
}t[787878];
int n,u,v,ans,maxx=-7878;
int num[787878];
bool pd[787878];
bool cmp(int a,int b)
{
return a>b;
}
void dfs(int zx,int up,int down)
{
if(zx==v)
{
ans=up*2+down;
return;
}
if(zx<1||zx>n) return;
pd[zx]=true;
if(t[zx].l>=1&&t[zx].l<=n&&pd[t[zx].l]==false) dfs(t[zx].l,up,down+1);
if(t[zx].r>=1&&t[zx].r<=n&&pd[t[zx].r]==false) dfs(t[zx].r,up,down+1);
if(t[zx].fa>=1&&t[zx].fa<=n&&pd[t[zx].fa]==false) dfs(t[zx].fa,up+1,down);
}
int main()
{
scanf("%d",&n);
t[1].fa=0; t[1].ceng=1;
for(int i=1;i<=(n-1);i++)
{
int x,y;
scanf("%d%d",&x,&y);
if(t[x].l==0) t[x].l=y;
else t[x].r=y;
t[y].fa=x;
t[y].ceng=t[x].ceng+1;
maxx=max(maxx,t[y].ceng);
}
scanf("%d%d",&u,&v);
for(int i=1;i<=n;i++)
num[t[i].ceng]++;
sort(num+1,num+n+1,cmp);
dfs(u,0,0);
printf("%d\n%d\n%d",maxx,num[1],ans);
return 0;
}
9