#include <bits/stdc++.h>

using namespace std;
const int N = 1e5 + 10;
int par[N], st[N], fn[N], h[N], timer = 0;
vector <int> g[N];

void dfs(int v, int p = 0, int height = 0)
{
    par[v] = p;
    h[timer] = height;
    st[v] = timer++;
    for (int u : g[v]) if (u != p) dfs(u, v, height + 1);
    fn[v] = timer;
}

int32_t main()
{
    int n, A, T; cin >> n >> T >> A;
    for (int i = 0; i < n - 1; i++) {
        int u, v; cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(A);
    int t = (h[st[T]] + 1) / 2 - 1;
    while (t--) T = par[T];
    int ans = 0;
    for (int i = st[T]; i < fn[T]; i++) ans = max(ans, h[i] - 1);
    cout << ans << "\n";
}
