#include<bits/stdc++.h>

using namespace std;

int main(void) {
    long n;
    cin >> n;
    long u, v;
    cin >> v >> u;
    u--, v--;

    vector<vector<long>> G(n);
    for(int i=0; i<n-1; i++) {
        long a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    vector<long> udis(n), vdis(n);

    {
        auto dfs = [&](auto dfs, long cur, long prev, long c) -> void{
            udis[cur] = c;
            for(auto &v: G[cur]) {
                if(v == prev) continue;
                dfs(dfs, v, cur, c+1);
            }
        };

        dfs(dfs, u, -1, 0);
    }

    long r = 0;
    {
        auto dfs = [&](auto dfs, long cur, long prev, long c) -> void {
            for(auto &v: G[cur]) {
                if(v == prev) continue;
                if(udis[v] < c) continue;

                r = max(r, long(udis[v] - (G[v].size())%2));

                dfs(dfs, v, cur, c+1);
            }
        };
        dfs(dfs, v, -1, 0);
    }
    cout << r << endl;
}
