#include<bits/stdc++.h>
#define MX 200000
using namespace std;
int n, x, y, dep[MX], ans, cnt[MX];
vector<int> e[MX];
void dfs(int x, int fa)
{
for(int i=0;i<e[x].size();i++)
{
int son = e[x][i];
if(son == fa)
continue;
dep[son] = dep[x] + 1;
dfs(son, x);
}
}
void dfs1(int x, int w, int frm)
{
if(x == y)
{
ans = w;
}
for(int i=0;i<e[x].size();i++)
{
int son = e[x][i];
if(son == frm)
continue;
if(dep[son] > dep[x])
dfs1(son, w + 1, x);
else
dfs1(son, w + 2, x);
}
}
int main()
{
scanf("%d", &n);
for(int i=1;i<n;i++)
{
int u, v;
scanf("%d%d", &u, &v);
e[u].push_back(v);
e[v].push_back(u);
}
scanf("%d%d", &x, &y);
dep[1] = 1;
dfs(1, 1);
dfs1(x, 0, 0);
int maxdep = 0;
int maxwid = 0;
for(int i=1;i<=n;i++)
{
maxdep = max(dep[i], maxdep);
cnt[dep[i]]++;
}
for(int i=1;i<=n;i++)
{
maxwid = max(cnt[i], maxwid);
}
printf("%d\n%d\n%d", maxdep, maxwid, ans);
}