package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	u := scanInt() - 1
	v := scanInt() - 1
	g := make([][]int, n)
	for i := 0; i < n-1; i++ {
		a, b := scanInt()-1, scanInt()-1
		g[a] = append(g[a], b)
		g[b] = append(g[b], a)
	}

	var dfs func(to, c int, arr []int)
	dfs = func(v, c int, arr []int) {
		for _, to := range g[v] {
			if arr[to] != -1 {
				continue
			}
			arr[to] = c
			dfs(to, c+1, arr)
		}
	}

	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = -1
	}
	a[v] = 0
	dfs(v, 1, a)

	ans := 0
	var dfs2 func(v, p, c int)
	dfs2 = func(v, p, c int) {
		for _, to := range g[v] {
			if to == p || a[to] < c {
				continue
			}
			t := a[to]
			if a[to]%2 != c%2 {
				t--
			}
			ans = max(ans, t)
			if a[to] == c {
				continue
			}
			dfs2(to, v, c+1)
		}
	}

	dfs2(u, -1, 1)

	fmt.Fprintln(wr, ans)

}
