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

const int MAX_N = 100100;
int du[MAX_N], dv[MAX_N];
vector<int> tree[MAX_N];
bool visited[MAX_N];
int N, u, v;

void dfs(int prev, int cur, int *d){
    for(int i = 0; i < tree[cur].size(); ++i) if(tree[cur][i] != prev){
        int leaf = tree[cur][i];
        d[leaf] = d[cur] + 1;
        dfs(cur, leaf, d);
    }
}

int main()
{
    scanf("%d %d %d", &N, &u, &v);
    --u, --v;
    for(int i = 0; i < N-1; ++i) {
        int a, b;
        scanf("%d %d", &a, &b);
        --a, --b;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }

    dfs(-1, u, du); dfs(-1, v, dv);
    int goal = u;
    for(int i = 0; i < N; ++i) if(du[i] < dv[i] && dv[goal] < dv[i]) goal = i;
    printf("%d\n", dv[goal]-1);
    return 0;
}