#include <iostream>
#include <vector>
#include <queue>
using namespace std;

vector<int> to[100005];
vector<int> dist;

void dfs(int v, int d=0, int p=-1) {
    dist[v] = d;
    for (int u : to[v]) {
        if (u == p) continue;
        dfs(u, d+1, v);
    }
}

int main()
{
    int n,u,v;
    cin >> n >> u >> v;
    u--;
    v--;
    for(int i=0; i<n-1; i++){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    dist = vector<int>(n);
    dfs(u);
    vector<int> du = dist;
    dist = vector<int>(n);
    dfs(v);
    vector<int> dv = dist;

    int ans = 0;
    for(int i=0; i<n;i++){
        if(dv[i] <= du[i] ) continue;
        ans = max(ans, dv[i] -1);
    }
    cout << ans << endl;
    return 0;
}