#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

int n, u, v, ans, d[2][100005];
vector<int> gr[100005];

void f(int p, int q, int z) {
	if(q!=-1) d[z][p] = d[z][q] + 1;
	for(int x:gr[p]) {
		if(x==q) continue;
		if(z==0 || d[1][p]+1 < d[0][x]) f(x, p, z);
	}
}

int main() {
	int i, t1, t2;
	cin >> n >> u >> v;
	for(i=0; i<n-1; i++) {
		scanf("%d%d", &t1, &t2);
		gr[t1].push_back(t2);
		gr[t2].push_back(t1);
	}
	f(v, -1, 0);
	for(i=1; i<=n; i++) d[1][i] = 1e9;
	d[1][u] = 0;
	f(u, -1, 1);
	for(i=1; i<=n; i++) if(d[1][i] != 1e9) ans = max(ans, d[0][i]-1);
	cout << ans;
	return 0;
}