import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int N, tk, ao;
    scan(N, tk, ao);
    tk--, ao--;
    auto adj = new int[][](N, 0);
    foreach (i ; 0 .. N - 1) {
        int ai, bi;
        scan(ai, bi);
        ai--, bi--;
        adj[ai] ~= bi;
        adj[bi] ~= ai;
    }

    auto par = new int[](N);
    par[] = -1;

    auto height = new int[](N);
    height[] = -1;

    auto depth = new int[](N);
    depth[] = -1;

    void dfs(int v, int p, int dep) {
        par[v] = p;
        depth[v] = dep;
        foreach (u ; adj[v]) if (u != p) {
            dfs(u, v, dep + 1);
            chmax(height[v], height[u]);
        }
        height[v] += 1;
    }

    dfs(ao, -1, 0);

    debug {
        writeln(par);
        writeln(depth);
        writeln(height);
    }

    int pos = tk;
    int upc = (depth[tk] + 1) / 2 - 1;
    int ans = upc;
    while (upc--) {
        pos = par[pos];
    }
    ans += height[pos] + (depth[tk] % 2 == 0);
    writeln(ans);
}






void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}
