#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
vector<int> ki[110000];
void dfs(int now,vector<int> &dist,int last = -1){
    for(int next:ki[now]){
        if(next == last)continue;
        dist[next] = dist[now] +1;
        dfs(next,dist,now);
    }
}
signed main(){
    int n,u,v;cin >> n >> u >> v;
    u--;v--;
    rep(i,n-1){
        int a,b;cin >> a >> b;
        a--;b--;
        ki[a].push_back(b);
        ki[b].push_back(a);
    }
    vector<int> takahashi(n,0),aoki(n,0);
    dfs(u,takahashi);
    dfs(v,aoki);
    int ans = 0;
    rep(i,n){
        
        if(takahashi[i] < aoki[i])ans = max(ans,aoki[i]);
    }
    cout << ans-1 << endl;


    return 0;
}