#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef long long ll;

vector<ll> to[100010];

int main(){
    ll n,ta,ao;cin>>n>>ta>>ao;
    ta--;ao--;
    rep(i,0,n){
        ll a,b;cin>>a>>b;
        a--;b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    vector<pair<ll,ll> > dis(n);//a,t
    rep(i,0,n)dis[i]=make_pair(-1,-1);
    queue<ll> q;
    q.push(ta);
    dis[ta].second=0;
    while(!q.empty()){
        ll now=q.front();
        q.pop();
        for(auto nx:to[now]){
            if(dis[nx].second!=-1)continue;
            dis[nx].second=dis[now].second+1;
            q.push(nx);
        }
    }
    q.push(ao);
    dis[ao].first=0;
    while(!q.empty()){
        ll now=q.front();
        q.pop();
        for(auto nx:to[now]){
            if(dis[nx].first!=-1)continue;
            dis[nx].first=dis[now].first+1;
            q.push(nx);
        }
    }
    sort(dis.begin(),dis.end(),greater<>());
    ll des;
    rep(i,0,n){
        if(dis[i].first>dis[i].second){
            des=i;
            break;
        }
    }
    cout<<dis[des].second+(dis[des].first-dis[des].second)/2<<endl;
}

    







