#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)
{
//cout<<src<<" "<<par<<endl;
    if(src==v)
        return vis[src]=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];
ll level1[100005];
ll z1[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;
    z1[src]=1;
    deque<ll>q;
    q.push_back(src);
    level1[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(z1[adj]==1)
                continue;
            level1[adj]=level1[src]+1;
            //cout<<level1[src]<<" "<<src<<" "<<adj<<" "<<level1[adj]<<" "<<level[adj]<<endl;
            if(level1[adj]>level[adj])
                continue;
            if(level1[adj]==level[adj])
            {
                high=max(high,level[adj]);
                continue;
            }

            high=max(high,level[adj]);
            q.push_back(adj);
            z1[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);
    }

    //cout<<"shajib"<<endl;
    bfs(u);
    bfs1(v);
    cout<<high<<endl;
}

