int edges[100001][100001], n, u, v, td[100001], ad[100001], a, b, res;

dfs (int arr[], int start, int step) {
    arr[start] = step;
    for (int i = 1; i <= n; i++) {
        if (edges[start][i] && !arr[i]) {
            dfs(arr, i, step + 1);
        }
    }
}

main () {
    scanf("%d %d %d", &n, &u, &v);
    for (int i = 1; i < n; i++) {
        scanf("%d %d", &a, &b);
        edges[a][b] = edges[b][a] = 1;
    }
    dfs(td, u, 1);
    dfs(ad, v, 1);
    for (int i = 1; i <= n; i++) {
        if (ad[i] > td[i] && ad[i] > res)
            res = ad[i];
    }

    printf("%d\n", res - 2);
}
