#include <iostream>
#include <vector>

using namespace std;

void dfs(vector< vector<int> > &g, vector<int> &dist, int v, int d=0, int p=-1) {
    dist[v] = d;
    for(auto u: g[v]) {
        if(u == p) continue;
        dfs(g, dist, u, d+1, v);
    }
    return;
}

int main(void) {
    int N, u, v;
    cin >> N >> u >> v;
    --u; --v;
    vector< vector<int> > g(N);
    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);
    }

    vector<int> distT(N), distA(N);
    dfs(g, distT, u);
    dfs(g, distA, v);

    int ans = 0;
    for(int i=0; i<N; i++) {
        if(distT[i] <= distA[i]) ans = max(ans, distA[i]-1);
    }

    cout << ans << endl;
    return 0;
}
