#include <iostream>
#include <vector>

using namespace std;

vector<int> g[100005];
int N, u, v;

vector<int> ret(100005);

void dfs(int now, int d, int par){
    ret[now] = d;
    for(auto next : g[now]){
        if(next == par) continue;
        dfs(next, d+1, now);
    }
}

vector<int> dist(int s){
    dfs(s, 0, -1);
    return ret;
}

int main(){
    cin >> N >> u >> v;

    for(int i=0; i<N-1; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    u--; v--;

    vector<int> td = dist(u);
    vector<int> ad = dist(v);

    int ans = 0;
    for(int i=0; i<N; i++){
        if(td[i] >= ad[i]) continue;
        ans = max(ans, ad[i]);
    }

    cout << ans-1 << endl;

    return 0;
}