#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#define N 100005
using namespace std;

int n, T, A, mx, h[N], v[N];
vector<int> a[N];
void f(int p, int q) {
	int i;
	if (h[p] != -1) return;
	h[p] = q;
	for (i = 0; i < a[p].size(); i++) {
		f(a[p][i], q + 1);
	}
}

void g(int p, int q) {
	int i;
	if (q > h[p]) return;
	if (v[p]) return;
	v[p] = 1;
	mx = max(mx, h[p]);
	for (i = 0; i < a[p].size(); i++) {
		g(a[p][i], q + 1);
	}
}

int main()
{
	int i, t1, t2;
	cin >> n >> T >> A;
	for (i = 0; i < n - 1; i++) {
		scanf ("%d %d", &t1, &t2);
		a[t1].push_back(t2);
		a[t2].push_back(t1);
	}
	memset(h, -1, sizeof(h));
	f(A, 0);
	g(T, 0);
    cout << mx - 1 << endl;
    return 0;
}
