#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)

int n, ut, va;
vector<vector<int>> g(100010);
vector<int> depth(100010), mxd(100010), par(100010);

void dfs(int v, int p) {
    par[v] = p;
    for (auto u : g[v])
        if (u != p) {
            depth[u] = depth[v] + 1;
            dfs(u, v);
            mxd[v] = max(mxd[u] + 1, mxd[v]);
        }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> ut >> va;
    rep(i, 1, n) {
        int a, b;
        cin >> a >> b;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }
    dfs(va, -1);
    ll ans = (depth[ut] - 1) / 2;
    ll x = depth[ut];
    rep(i, 0, ans) ut = par[ut];
    cout << ans + mxd[ut] + (x - 1) % 2 << endl;

    return 0;
}