#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
const ll maxs = 1e5+5;

#define pb push_back

ll n,a,b;
std::vector<ll> Tree[maxs];
ll dist[2][maxs];

void go(ll s,ll p,ll ind)
{
    dist[ind][s] = dist[ind][p]+1;
    for(auto d : Tree[s])
    {
        if(d != p)
            go(d,s,ind);
    }
}

int main()
{
    cin>>n>>a>>b;
    for(ll i=0;i<n-1;i++)
    {
        ll s,d;
        cin>>s>>d;
        Tree[s].pb(d);
        Tree[d].pb(s);
    }
    dist[0][0] = dist[1][0] = -1;
    go(a,0,0);
    go(b,0,1);
    
    ll ans=0;
    for(ll i=1;i<=n;i++)
    {
        if( dist[0][i] < dist[1][i] )
        {
            ans = max(ans,dist[1][i] - 1);
        }
    }
    std::cout << ans << std::endl;
    return 0;
}