#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let u: usize = sc.cin::<usize>() - 1; // nigeru
    let v: usize = sc.cin::<usize>() - 1; // oikakaeru

    let mut g = vec![vec![]; n];
    for i in 1..n {
        let a: usize = sc.cin::<usize>() - 1;
        let b: usize = sc.cin::<usize>() - 1;
        g[a].push(b);
        g[b].push(a);
    }

    let mut h = vec![vec![]; n];  // digraph from v
    {
        let mut stack = vec![v];
        let mut visited = vec![false; n];
        while let Some(v) = stack.pop() {
            if visited[v] { continue }
            visited[v] = true;
            for &u in g[v].iter() {
                if visited[u] { continue }
                h[v].push(u);
                stack.push(u)
            }
        }
    }

    let mut r = vec![vec![]; n];  // rev of h
    {
        for u in 0..n {
            for &v in h[u].iter() {
                r[v].push(u);
            }
        }
    }

    let mut line = vec![];
    {
        let mut u = u;
        while u != v {
            line.push(u);
            u = r[u][0];
        }
    }
    let ans1 = (line.len() - 1) / 2;

    let mut depth = vec![0; n];
    {
        let mut leaves = vec![];
        for i in 0..n {
            if h[i].len() == 0 {
                leaves.push(i);
                depth[i] = 0;
            }
        }
        while let Some(v) = leaves.pop() {
            for &u in r[v].iter() {
                if depth[u] < depth[v] + 1 {
                    depth[u] = depth[v] + 1;
                    leaves.push(u);
                }
            }
        }
    }
    let ans2 = depth[line[ans1]];
    let mut ans = ans1 + ans2;
    if line.len() % 2 == 0 {
        ans += 1;
    }
    put!(ans);

}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 26876