// -*- coding:utf-8-unix -*-

use std::cmp::*;
use std::collections::*;
use std::fs::File;
use std::io::prelude::*;
use std::io::*;
use std::vec;

const INF: i64 = 1223372036854775807;
const MEM_SIZE: usize = 202020;
const MOD: i64 = 1000000007;
use std::cmp::*;
use std::collections::*;
use std::io::stdin;
use std::io::stdout;
use std::io::Write;
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

#[allow(unused_macros)]
macro_rules! p {
    ([$($x:expr), *]) => {{
        let mut f = true;
        $(
            print!("{}{}", if f {""} else {" "}, $x);
            f = false;
        )*
78786    print!("\n");
    }};
    ($x:expr) => {{
        let mut f = true;
        for a in $x.iter() {
            print!("{}{}", if f {""} else {" "}, a);
            f = false;
        }
        print!("\n");
    }};
}
#[allow(dead_code)]
fn readii() -> (i64, i64) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<i64>().unwrap(),
        iter.next().unwrap().parse::<i64>().unwrap(),
    )
}
#[allow(dead_code)]
fn readuu() -> (usize, usize) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<usize>().unwrap(),
        iter.next().unwrap().parse::<usize>().unwrap(),
    )
}

#[allow(dead_code)]
fn readuuu() -> (usize, usize, usize) {
    let mut str = String::new();
    let _ = stdin().read_line(&mut str).unwrap();
    let mut iter = str.split_whitespace();
    (
        iter.next().unwrap().parse::<usize>().unwrap(),
        iter.next().unwrap().parse::<usize>().unwrap(),
        iter.next().unwrap().parse::<usize>().unwrap(),
    )
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn graph_dfs(v: usize, p: usize, depth: &mut Vec<i64>, graph: &Vec<Vec<usize>>) {
    let mut res: (i64) = (0);
    if (p != INF as usize) {
        depth[v] = depth[p] + 1;
    } else {
        depth[v] = 0;
    }
    // println!("{:?}", v);

    for nv in graph[v].iter() {
        if (*nv == p || depth[*nv] != -1) {
            continue;
        }
        graph_dfs(*nv, v, depth, graph);
    }
    // return res;
}

fn solve() {
    let (mut n, mut u, mut v) = readuuu();
    u -= 1;
    v -= 1;
    let mut d1: Vec<i64> = vec![-1; n];
    let mut d2: Vec<i64> = vec![-1; n];
    let mut vv: Vec<Vec<usize>> = vec![vec![0; (0) as usize]; (n) as usize];

    for i in 0..n - 1 {
        let (mut a, mut b) = readuu();
        a -= 1;
        b -= 1;
        vv[a].push(b);
        vv[b].push(a);
    }
    graph_dfs(u, INF as usize, &mut d1, &vv);
    graph_dfs(v, INF as usize, &mut d2, &vv);
    let mut dist: Vec<i64> = vec![0; n];
    for i in 0..n {
        dist[i] = d1[i] - d2[i];
    }
    for i in 0..n {
        if (vv[i].len() == 1) {
            dist[i] = -1;
        }
    }
    let mut res = 0;
    let mut dd = -1 * INF;
    for i in 0..n {
        if (dd < dist[i]) {
            res = i;
            dd = max(dd, dist[i]);
        }
    }

    return;
}
fn main() {
    solve()
}
