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

int N, T, A;
vector<int> edges[100000];

int dist[100000];
void dfs1(int i, int p){
    for(int j : edges[i]) if(j != p){
        dist[j] = dist[i] + 1;
        dfs1(j, i);
    }
}

int ans;
void dfs2(int i, int p, int d){
    if(d >= dist[i]) return;
    ans = max(ans, dist[i]-1);
    for(int j : edges[i]) if(j != p) dfs2(j, i, d+1);
}

int main(){
    cin >> N >> T >> A;
    T--; A--;
    for(int i=0; i<N-1; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    dfs1(A, -1);
    dfs2(T, -1, 0);
    cout << ans << endl;
    return 0;
}
