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

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto u = s[1] - 1;
    auto v = s[2] - 1;
    auto G = new int[][](N);
    foreach (i; 0..N-1) {
        s = readln.split.map!(to!int);
        G[s[0]-1] ~= s[1]-1;
        G[s[1]-1] ~= s[0]-1;
    }

    auto d = new int[](N);
    auto b = new bool[](N);

    bool dfs2(int n, int p) {
        if (n == u) return b[n] = true;
        foreach (m; G[n]) if (p != m) {
            if (dfs2(m, n)) return b[n] = true;
        }
        return false;
    }

    int dfs(int n, int p) {
        foreach (m; G[n]) if (m != p) {
            if (p == -1 && !b[m] ) continue;
            d[n] = max(d[n], dfs(m, n) + 1);
        }
        return d[n];
    }

    dfs2(v, -1);
    dfs(v, -1);
    int ans = max(0, d[v] - 1);
    ans.writeln;
}