/*
lca能解决的事为什么要贴上搜索的标签。。
*/
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define maxn 1000010
int n,s1,s2,head[maxn*2],num,son[maxn],sz[maxn],top[maxn],fa[maxn],dep[maxn];
struct node{
int to,pre;
}e[maxn*2];
void Insert(int from,int to){
e[++num].to=to;
e[num].pre=head[from];
head[from]=num;
}
void dfs1(int u,int father){
sz[u]=1;
fa[u]=father;
dep[u]=dep[father]+1;
for(int i=head[u];i;i=e[i].pre){
int v=e[i].to;
if(v==father)continue;
dfs1(v,u);
sz[u]+=sz[v];
if(!son[u]||sz[v]>sz[son[u]])son[u]=v;
}
}
void dfs2(int u,int father){
top[u]=father;
if(son[u])dfs2(son[u],father);
else return;
for(int i=head[u];i;i=e[i].pre){
int v=e[i].to;
if(v==fa[u]||v==son[u])continue;
dfs2(v,v);
}
}
int lca(int x,int y){
while(top[x]!=top[y]){
if(dep[top[x]]<dep[top[y]])swap(x,y);
x=fa[top[x]];
}
if(dep[x]<dep[y])return x;
else return y;
}
int main(){
freopen("Cola.txt","r",stdin);
scanf("%d",&n);
int x,y;
for(int i=1;i<n;i++){
scanf("%d%d",&x,&y);
Insert(y,x);
Insert(x,y);
}
scanf("%d%d",&s1,&s2);
dfs1(1,0);
dfs2(1,1);
printf("%d",lca(s1,s2));
}