#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template<typename T>
using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define ll long long
#define __   ios_base::sync_with_stdio(0);cin.tie();cout.tie();
#define mod 1000000007

ll Set(ll N,ll pos){ return N=N | (1<<pos); }
ll reset(ll N,ll pos){ return N= N & ~(1<<pos); }
bool check(ll N,ll pos){ return (bool)(N & (1<<pos)); }


ll ar[]={0,0,1,-1};
ll br[]={1,-1,0,0};

string s;
ll n,m,u,v;
ll arr[500000];
ll brr[500000];

vector<ll>graph[100005];

ll vis[100005];

bool dfs(ll src,ll par){

if(src==v) return 1;

ll i,j,n=graph[src].size();
ll chk=0,adj;

for(i=0;i<n;i++){
    adj=graph[src][i];
    if(adj!=par)chk=chk|dfs(adj,src);
}
return vis[src]=chk;
}

ll level[100005];
ll z[100005];
void bfs(ll src){

ll adj,i,j,n;
deque<ll>q;
q.push_back(src);
level[src]=0;
z[src]=1;
while(!q.empty()){
    ll adj;
    src=q.front();
    q.pop_front();
    //cout<<src<<endl;
    for(i=0;i<graph[src].size();i++){
        adj=graph[src][i];
        if(z[adj]==1) continue;
        level[adj]=level[src]+1;
    q.push_back(adj);
    z[adj]=1;
    }
}

}
ll high;
void bfs1(ll src){

ll adj,i,j,n;
z[src]=1;
deque<ll>q;
q.push_back(src);
level[src]=0;
while(!q.empty()){
    ll adj;
    src=q.front();
    q.pop_front();

    for(i=0;i<graph[src].size();i++){
        adj=graph[src][i];
        if(vis[adj]==1) continue;
        if(z[adj]==1) continue;
        level[adj]=level[src]+1;
        high=max(high,level[adj]);
        q.push_back(adj);
        z[adj]=1;
    }
}

}

int main()
{__
        ll i,j,a,b;

        cin>>n>>u>>v;

        for(i=0;i<n-1;i++){
            cin>>a>>b;
            graph[a].push_back(b);
            graph[b].push_back(a);
        }

        dfs(u,-1);
        //cout<<"shajib"<<endl;
        bfs(u);
        ll ans=(level[v]-level[u])/2+(level[v]-level[u])%2;
        //cout<<vis[2]<<endl;
        memset(level,0,sizeof(level));
        memset(z,0,sizeof(z));
        bfs1(u);
        cout<<high+ans<<endl;
}

