#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
typedef long long ll;
#define MAX 100100
using namespace std;

vector<int> e[MAX];
int vu[MAX], vv[MAX];

void f(int x, int* v) {
	for (int i = 0; i < e[x].size(); i++) {
		if (v[e[x][i]] == 0) {
			v[e[x][i]] = v[x] + 1;
			f(e[x][i], v);
		}
	}
}
int main()
{	
	int N, u, v; 
	scanf("%d%d%d", &N, &u, &v);
	for (int i = 0; i < N - 1; i++) {
		int x, y; scanf("%d%d", &x, &y);
		e[x].push_back(y);
		e[y].push_back(x);
	}
	vu[u] = 1;
	f(u, vu);
	vv[v] = 1;
	f(v, vv);
	int max = 0;
	for (int i = 1; i <= N; i++) {
		if (vu[i] < vv[i] && max < vv[i]) max = vv[i];
	}
	printf("%d", max - 2);
	return 0;
}