#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+100;
vector<int> g[N];
int d[N],mx[N],fa[N],n,a,t;

void dfs1(int u,int f){
    fa[u]=f; mx[u]=d[u]=d[f]+1;
    for(auto v:g[u]){
        if(v==f) continue;
        dfs1(v,u); mx[u]=max(mx[u],mx[v]);
    }
}

int ans=0;
int main(){
    scanf("%d %d %d",&n,&t,&a);
    for(int i=1,u,v;i<n;++i){
        scanf("%d %d",&u,&v);
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs1(a,a);
    int k=d[t]/2-1;
    if(d[t]%2==1) ans=1;
    while(k--){
        ans++; t=fa[t];
    }
    //printf("%d %d %d\n",t,mx[t],d[t]);
    ans+=mx[t]-d[t];
    printf("%d\n",ans);
}